Error messages now display meter/measure in question.

This commit is contained in:
Birunthan Mohanathas 2010-09-21 16:45:29 +00:00
parent 77ac096f2c
commit 11588043de
12 changed files with 82 additions and 75 deletions

View File

@ -679,8 +679,8 @@ CMeasure* CMeasure::Create(const WCHAR* measure, CMeterWindow* meterWindow)
return new CMeasureCalc(meterWindow);
}
// Error
throw CError(std::wstring(L"No such measure: ") + measure, __LINE__, __FILE__);
// Error
throw CError(std::wstring(L"Measure=") + measure + L" is not valid.", __LINE__, __FILE__);
return NULL;
}

View File

@ -53,58 +53,58 @@ CMeasureRegistry::~CMeasureRegistry()
*/
bool CMeasureRegistry::Update()
{
if (!CMeasure::PreUpdate()) return false;
if (!CMeasure::PreUpdate()) return false;
if(m_RegKey != NULL)
{
DWORD size = 4096;
WCHAR data[4096];
DWORD type = 0;
if(m_RegKey != NULL)
{
DWORD size = 4096;
WCHAR data[4096];
DWORD type = 0;
if(RegQueryValueEx(m_RegKey,
m_RegValueName.c_str(),
NULL,
(LPDWORD)&type,
(LPBYTE)&data,
(LPDWORD)&size) == ERROR_SUCCESS)
{
switch(type)
{
case REG_DWORD:
m_Value = *((LPDWORD)&data);
m_StringValue.erase();
break;
if(RegQueryValueEx(m_RegKey,
m_RegValueName.c_str(),
NULL,
(LPDWORD)&type,
(LPBYTE)&data,
(LPDWORD)&size) == ERROR_SUCCESS)
{
switch(type)
{
case REG_DWORD:
m_Value = *((LPDWORD)&data);
m_StringValue.erase();
break;
case REG_SZ:
case REG_EXPAND_SZ:
case REG_MULTI_SZ:
m_Value = 0.0;
m_StringValue = data;
break;
case REG_SZ:
case REG_EXPAND_SZ:
case REG_MULTI_SZ:
m_Value = 0.0;
m_StringValue = data;
break;
case REG_QWORD:
m_Value = (double)((LARGE_INTEGER*)&data)->QuadPart;
m_StringValue.erase();
break;
case REG_QWORD:
m_Value = (double)((LARGE_INTEGER*)&data)->QuadPart;
m_StringValue.erase();
break;
default: // Other types are not supported
m_Value = 0.0;
m_StringValue.erase();
}
}
else
{
m_Value = 0.0;
m_StringValue.erase();
RegOpenKeyEx(m_HKey, m_RegKeyName.c_str(), 0, KEY_READ, &m_RegKey);
}
}
else
{
RegOpenKeyEx(m_HKey, m_RegKeyName.c_str(), 0, KEY_READ, &m_RegKey);
}
default: // Other types are not supported
m_Value = 0.0;
m_StringValue.erase();
}
}
else
{
m_Value = 0.0;
m_StringValue.erase();
RegOpenKeyEx(m_HKey, m_RegKeyName.c_str(), 0, KEY_READ, &m_RegKey);
}
}
else
{
RegOpenKeyEx(m_HKey, m_RegKeyName.c_str(), 0, KEY_READ, &m_RegKey);
}
return PostUpdate();
return PostUpdate();
}
/*
@ -150,7 +150,7 @@ void CMeasureRegistry::ReadConfig(CConfigParser& parser, const WCHAR* section)
}
else
{
throw CError(std::wstring(L"No such HKEY: ") + keyname, __LINE__, __FILE__);
throw CError(std::wstring(L"HKEY=") + keyname + L" is not valid in measure [" + section + L"].", __LINE__, __FILE__);
}
m_RegKeyName = parser.ReadString(section, L"RegKey", L"");
@ -164,7 +164,7 @@ void CMeasureRegistry::ReadConfig(CConfigParser& parser, const WCHAR* section)
// Try to open the key
if(m_RegKey) RegCloseKey(m_RegKey);
RegOpenKeyEx(m_HKey, m_RegKeyName.c_str(), 0, KEY_READ, &m_RegKey);
RegOpenKeyEx(m_HKey, m_RegKeyName.c_str(), 0, KEY_READ, &m_RegKey);
}
/*
@ -176,7 +176,7 @@ void CMeasureRegistry::ReadConfig(CConfigParser& parser, const WCHAR* section)
*/
const WCHAR* CMeasureRegistry::GetStringValue(bool autoScale, double scale, int decimals, bool percentual)
{
if (m_StringValue.empty())
if (m_StringValue.empty())
{
return CMeasure::GetStringValue(autoScale, scale, decimals, percentual);
}

View File

@ -59,10 +59,10 @@ int GetYearDay(int year, int month, int day)
CMeasureTime::CMeasureTime(CMeterWindow* meterWindow) : CMeasure(meterWindow)
{
/* Set time zone from TZ environment variable. If TZ is not set,
* the operating system is queried to obtain the default value
* for the variable.
*/
_tzset();
* the operating system is queried to obtain the default value
* for the variable.
*/
tzset();
m_DeltaTime.QuadPart = 0;
m_Time.QuadPart = 0;

View File

@ -406,7 +406,7 @@ void CMeter::BindMeasure(std::list<CMeasure*>& measures)
// The meter is not bound to anything
if (m_MeasureName.empty())
{
throw CError(std::wstring(L"The meter [") + m_Name + L"] is not bound to anything!", __LINE__, __FILE__);
throw CError(std::wstring(L"The meter [") + m_Name + L"] is not bound to anything!", __LINE__, __FILE__);
}
// Go through the list and check it there is a measure for us
@ -420,8 +420,8 @@ void CMeter::BindMeasure(std::list<CMeasure*>& measures)
}
}
// Error :)
throw CError(std::wstring(L"The meter [") + m_Name + L"] cannot be bound with [" + m_MeasureName + L"]!", __LINE__, __FILE__);
// Error :)
throw CError(std::wstring(L"The meter [") + m_Name + L"] cannot be bound with [" + m_MeasureName + L"]!", __LINE__, __FILE__);
}
/*
@ -470,8 +470,8 @@ CMeter* CMeter::Create(const WCHAR* meter, CMeterWindow* meterWindow)
return new CMeterButton(meterWindow);
}
// Error
throw CError(std::wstring(L"No such meter: ") + meter, __LINE__, __FILE__);
// Error
throw CError(std::wstring(L"Meter=") + meter + L" is not valid.", __LINE__, __FILE__);
return NULL;
}

View File

@ -133,7 +133,7 @@ void CMeterBar::ReadConfig(const WCHAR* section)
}
else
{
throw CError(std::wstring(L"No such BarOrientation: ") + orientation, __LINE__, __FILE__);
throw CError(std::wstring(L"BarOrientation=") + orientation + L" is not valid in meter [" + m_Name + L"].", __LINE__, __FILE__);
}
if (m_Initialized)

View File

@ -214,7 +214,7 @@ void CMeterBitmap::ReadConfig(const WCHAR* section)
}
else
{
throw CError(std::wstring(L"No such BitmapAlign: ") + align, __LINE__, __FILE__);
throw CError(std::wstring(L"BitmapAlign=") + align + L" is not valid in meter [" + m_Name + L"].", __LINE__, __FILE__);
}
if (m_Initialized)

View File

@ -541,7 +541,7 @@ void CMeterImage::ReadConfig(const WCHAR* section)
}
else
{
throw CError(std::wstring(L"No such ImageFlip: ") + flip, __LINE__, __FILE__);
throw CError(std::wstring(L"ImageFlip=") + flip + L" is not valid in meter [" + m_Name + L"].", __LINE__, __FILE__);
}
m_Rotate = (REAL)parser.ReadFloat(section, L"ImageRotate", 0.0);

View File

@ -201,7 +201,7 @@ void CMeterString::Initialize()
if (m_FontSize != 0)
{
throw CError(std::wstring(L"Unable to create font: ") + m_FontFace, __LINE__, __FILE__);
throw CError(std::wstring(L"Unable to create font: ") + m_FontFace, __LINE__, __FILE__);
}
}
}
@ -301,7 +301,7 @@ void CMeterString::ReadConfig(const WCHAR* section)
}
else
{
throw CError(std::wstring(L"No such StringAlign: ") + align, __LINE__, __FILE__);
throw CError(std::wstring(L"StringAlign=") + align + L" is not valid in meter [" + m_Name + L"].", __LINE__, __FILE__);
}
std::wstring stringCase;
@ -323,8 +323,10 @@ void CMeterString::ReadConfig(const WCHAR* section)
{
m_textCase = TEXTCASE_PROPER;
}
else
{
throw CError(std::wstring(L"StringCase=") + stringCase + L" is not valid in meter [" + m_Name + L"].", __LINE__, __FILE__);
}
std::wstring style;
style = parser.ReadString(section, L"StringStyle", L"NORMAL");
@ -347,7 +349,7 @@ void CMeterString::ReadConfig(const WCHAR* section)
}
else
{
throw CError(std::wstring(L"No such StringStyle: ") + style, __LINE__, __FILE__);
throw CError(std::wstring(L"StringStyle=") + style + L" is not valid in meter [" + m_Name + L"].", __LINE__, __FILE__);
}
std::wstring effect;
@ -367,7 +369,7 @@ void CMeterString::ReadConfig(const WCHAR* section)
}
else
{
throw CError(std::wstring(L"No such StringEffect: ") + effect, __LINE__, __FILE__);
throw CError(std::wstring(L"StringEffect=") + effect + L" is not valid in meter [" + m_Name + L"].", __LINE__, __FILE__);
}
if (-1 != (int)parser.ReadFormula(section, L"W", -1) && -1 != (int)parser.ReadFormula(section, L"H", -1))
@ -613,7 +615,7 @@ void CMeterString::BindMeasure(std::list<CMeasure*>& measures)
if (i == measures.end())
{
throw CError(std::wstring(L"The meter [") + m_Name + L"] cannot be bound with [" + (*j) + L"]!", __LINE__, __FILE__);
throw CError(std::wstring(L"The meter [") + m_Name + L"] cannot be bound with [" + (*j) + L"]!", __LINE__, __FILE__);
}
}
CMeter::SetAllMeasures(m_Measures);

View File

@ -100,8 +100,9 @@ UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id)
}
else
{
std::wstring error = L"No such RecycleType: ";
std::wstring error = L"RecycleType=";
error += type;
error += L" is not valid in measure [" + section + L"].";
MessageBox(NULL, error.c_str(), L"Rainmeter", MB_OK | MB_TOPMOST | MB_ICONEXCLAMATION);
}
}

View File

@ -113,8 +113,9 @@ UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id)
}
else
{
std::wstring error = L"No such GDICountType: ";
std::wstring error = L"GDICountType=";
error += type;
error += L" is not valid in measure [" + section + L"].";
MessageBox(NULL, error.c_str(), L"Rainmeter", MB_OK | MB_TOPMOST | MB_ICONEXCLAMATION);
}
}

View File

@ -111,8 +111,9 @@ UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id)
}
else
{
std::wstring error = L"No such SpeedFanScale: ";
std::wstring error = L"SpeedFanScale=";
error += scale;
error += L" is not valid in measure [" + section + L"]." ;
MessageBox(NULL, error.c_str(), L"Rainmeter", MB_OK | MB_TOPMOST | MB_ICONEXCLAMATION);
}
}
@ -127,8 +128,9 @@ UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id)
}
else
{
std::wstring error = L"No such SpeedFanType: ";
std::wstring error = L"SpeedFanType=";
error += type;
error += L" is not valid in measure [" + section + L"]." ;
MessageBox(NULL, error.c_str(), L"Rainmeter", MB_OK | MB_TOPMOST | MB_ICONEXCLAMATION);
}
}

View File

@ -207,8 +207,9 @@ UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id)
}
else
{
std::wstring error = L"No such SysInfoType: ";
std::wstring error = L"SysInfoType=";
error += type;
error += L" is not valid in measure [" + section + L"]." ;
MessageBox(NULL, error.c_str(), L"Rainmeter", MB_OK | MB_TOPMOST | MB_ICONEXCLAMATION);
}
}