From 11588043de0b7a1901063b62a98553cc8adbe64c Mon Sep 17 00:00:00 2001 From: Birunthan Mohanathas Date: Tue, 21 Sep 2010 16:45:29 +0000 Subject: [PATCH] Error messages now display meter/measure in question. --- Library/Measure.cpp | 4 +- Library/MeasureRegistry.cpp | 98 +++++++++---------- Library/MeasureTime.cpp | 8 +- Library/Meter.cpp | 10 +- Library/MeterBar.cpp | 2 +- Library/MeterBitmap.cpp | 2 +- Library/MeterImage.cpp | 2 +- Library/MeterString.cpp | 16 +-- .../PluginRecycleManager/RecycleManager.cpp | 3 +- Plugins/PluginResMon/ResMon.cpp | 3 +- Plugins/PluginSpeedFan/SpeedFanPlugin.cpp | 6 +- Plugins/PluginSysInfo/SysInfo.cpp | 3 +- 12 files changed, 82 insertions(+), 75 deletions(-) diff --git a/Library/Measure.cpp b/Library/Measure.cpp index 0f9963b0..885fcd53 100644 --- a/Library/Measure.cpp +++ b/Library/Measure.cpp @@ -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; } diff --git a/Library/MeasureRegistry.cpp b/Library/MeasureRegistry.cpp index fbf67c9f..84a3b1fc 100644 --- a/Library/MeasureRegistry.cpp +++ b/Library/MeasureRegistry.cpp @@ -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); } diff --git a/Library/MeasureTime.cpp b/Library/MeasureTime.cpp index 3c4f1000..07143c2f 100644 --- a/Library/MeasureTime.cpp +++ b/Library/MeasureTime.cpp @@ -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; diff --git a/Library/Meter.cpp b/Library/Meter.cpp index 35fcbe78..9447a80e 100644 --- a/Library/Meter.cpp +++ b/Library/Meter.cpp @@ -406,7 +406,7 @@ void CMeter::BindMeasure(std::list& 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& 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; } diff --git a/Library/MeterBar.cpp b/Library/MeterBar.cpp index f08a296b..2e32ade1 100644 --- a/Library/MeterBar.cpp +++ b/Library/MeterBar.cpp @@ -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) diff --git a/Library/MeterBitmap.cpp b/Library/MeterBitmap.cpp index 6ca2d820..5df75723 100644 --- a/Library/MeterBitmap.cpp +++ b/Library/MeterBitmap.cpp @@ -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) diff --git a/Library/MeterImage.cpp b/Library/MeterImage.cpp index 0ef74858..bd29e3d7 100644 --- a/Library/MeterImage.cpp +++ b/Library/MeterImage.cpp @@ -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); diff --git a/Library/MeterString.cpp b/Library/MeterString.cpp index 7aabf08b..13087202 100644 --- a/Library/MeterString.cpp +++ b/Library/MeterString.cpp @@ -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& 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); diff --git a/Plugins/PluginRecycleManager/RecycleManager.cpp b/Plugins/PluginRecycleManager/RecycleManager.cpp index 0d6b2096..49bc786f 100644 --- a/Plugins/PluginRecycleManager/RecycleManager.cpp +++ b/Plugins/PluginRecycleManager/RecycleManager.cpp @@ -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); } } diff --git a/Plugins/PluginResMon/ResMon.cpp b/Plugins/PluginResMon/ResMon.cpp index 86f09d56..50757616 100644 --- a/Plugins/PluginResMon/ResMon.cpp +++ b/Plugins/PluginResMon/ResMon.cpp @@ -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); } } diff --git a/Plugins/PluginSpeedFan/SpeedFanPlugin.cpp b/Plugins/PluginSpeedFan/SpeedFanPlugin.cpp index 9c4c7a62..23c89487 100644 --- a/Plugins/PluginSpeedFan/SpeedFanPlugin.cpp +++ b/Plugins/PluginSpeedFan/SpeedFanPlugin.cpp @@ -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); } } diff --git a/Plugins/PluginSysInfo/SysInfo.cpp b/Plugins/PluginSysInfo/SysInfo.cpp index 27412bb0..82131357 100644 --- a/Plugins/PluginSysInfo/SysInfo.cpp +++ b/Plugins/PluginSysInfo/SysInfo.cpp @@ -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); } }