Generic exception, used as base class for other types
| 129 | |
| 130 | // Generic exception, used as base class for other types |
| 131 | class Exception |
| 132 | { |
| 133 | |
| 134 | public: |
| 135 | |
| 136 | Exception() |
| 137 | { |
| 138 | } |
| 139 | |
| 140 | // Specify an actual error message |
| 141 | Exception(const std::wstring& exceptionMessage) : message(exceptionMessage) |
| 142 | { |
| 143 | } |
| 144 | |
| 145 | Exception(const std::string& exceptionMessage) |
| 146 | { |
| 147 | wchar buffer[512]; |
| 148 | MultiByteToWideChar(CP_ACP, 0, exceptionMessage.c_str(), -1, buffer, 512); |
| 149 | message = std::wstring(buffer); |
| 150 | } |
| 151 | |
| 152 | // Retrieve that error message |
| 153 | const std::wstring& GetMessage() const throw() |
| 154 | { |
| 155 | return message; |
| 156 | } |
| 157 | |
| 158 | void ShowErrorMessage() const throw () |
| 159 | { |
| 160 | MessageBox(NULL, message.c_str(), L"Error", MB_OK|MB_ICONERROR); |
| 161 | } |
| 162 | |
| 163 | protected: |
| 164 | |
| 165 | std::wstring message; // The error message |
| 166 | }; |
| 167 | |
| 168 | // Exception thrown when a Win32 function fails. |
| 169 | class Win32Exception : public Exception |
no outgoing calls
no test coverage detected