Exception thrown when a Win32 function fails.
| 167 | |
| 168 | // Exception thrown when a Win32 function fails. |
| 169 | class Win32Exception : public Exception |
| 170 | { |
| 171 | |
| 172 | public: |
| 173 | |
| 174 | // Obtains a string for the specified Win32 error code |
| 175 | Win32Exception(DWORD code, const wchar* msgPrefix = nullptr) : errorCode(code) |
| 176 | { |
| 177 | wchar errorString[MAX_PATH]; |
| 178 | ::FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, |
| 179 | 0, |
| 180 | errorCode, |
| 181 | MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), |
| 182 | errorString, |
| 183 | MAX_PATH, |
| 184 | NULL ); |
| 185 | |
| 186 | message = L"Win32 Error: "; |
| 187 | if(msgPrefix) |
| 188 | message += msgPrefix; |
| 189 | message += errorString; |
| 190 | } |
| 191 | |
| 192 | // Retrieve the error code |
| 193 | DWORD GetErrorCode() const throw () |
| 194 | { |
| 195 | return errorCode; |
| 196 | } |
| 197 | |
| 198 | protected: |
| 199 | |
| 200 | DWORD errorCode; // The Win32 error code |
| 201 | |
| 202 | }; |
| 203 | |
| 204 | // Exception thrown when a DirectX Function fails |
| 205 | class DXException : public Exception |
no outgoing calls
no test coverage detected