An exception type to encapsulate errors presented by the system API.
More...
#include <system_exception.hpp>
|
| template<typename... MessageArgs> |
| | system_exception (std::string const &file, std::string const &function, uint32_t line, DWORD error_code, MessageArgs &&...message) noexcept |
| | Construct an exception with a formatted description of the error. More...
|
| |
|
| virtual char const * | what () const noexcept override |
| | Return a message describing the exception that occurred. More...
|
| |
|
|
DWORD const | m_error_code |
| | The Windows error code that caused this exception.
|
| |
| std::string const | m_what |
| |
An exception type to encapsulate errors presented by the system API.
Most notably, this exception type takes a numerical error code (e.g., errno), and produces a coherent message based on that error for the result of what().
- Author
- Matt Bisson
- Date
- 5 August, 2014
- Since
- PSystem 2.0
- Version
- PSystem 2.0
- See also
- THROW_WINDOWS_EXCEPTION
-
THROW_WINDOWS_EXCEPTION_F
- Todo:
Make a windows_exception that derives from this; allow errno in a different exception type.
Remove the duplicate m_what members.
template<typename... MessageArgs>
| psystem::exception::system_exception::system_exception |
( |
std::string const & |
file, |
|
|
std::string const & |
function, |
|
|
uint32_t |
line, |
|
|
DWORD |
error_code, |
|
|
MessageArgs &&... |
message |
|
) |
| |
|
inlinenoexcept |
Construct an exception with a formatted description of the error.
- Parameters
-
| [in] | file | The source file where the exception occurred. |
| [in] | function | The function in the source where the exception occurred. |
| [in] | line | The line in file where the exception occurred. |
| [in] | error_code | This is an OS-specific error code that will be translated into a textual description of the problem. Presumably, this is an errno or GetLastError() code that was raised as the result of a system API failure. |
| [in] | message | This should be in a printf message/args style calling convention. |
| DWORD psystem::exception::system_exception::error_code |
( |
| ) |
const |
|
noexcept |
Return the Windows error code that caused the exception.
- Returns
- Check the Windows API for possible error codes thrown by Win32 functions.
| std::string psystem::exception::system_exception::get_windows_error |
( |
DWORD |
error_code | ) |
|
|
staticprivatenoexcept |
Given a Windows system error code, retrieve a textual description of the error.
- Parameters
-
| [in] | error_code | The Windows error code (usually retrieved from the Win32 GetLastError() function). |
- Returns
- A
std::string containing the error message.
- Todo:
- *NIX version of FormatMessage...
| char const * psystem::exception::system_exception::what |
( |
| ) |
const |
|
overridevirtualnoexcept |
Return a message describing the exception that occurred.
- Returns
- A pointer to a null-terminated C string with content related to the exception. This points to valid memory until the underlying base_exception instance is destroyed.
- Todo:
- Remove me
Reimplemented from psystem::exception::base_exception.
| #define THROW_WINDOWS_EXCEPTION |
( |
|
err, |
|
|
|
msg |
|
) |
| |
|
related |
Value:{ \
__FILE__, __FUNCTION__, __LINE__, err, msg) ; \
}
Throw a Windows API error as an exception with a brief description.
The result of the psystem::exception::system_exception::what() method will be something like "[error message]: [msg]".
- Parameters
-
| err | The Windows API error code. |
| msg | A brief description of the error (other than the message that will be formated automatically. |
| #define THROW_WINDOWS_EXCEPTION_F |
( |
|
err, |
|
|
|
msg, |
|
|
|
... |
|
) |
| |
|
related |
Value:{ \
__FILE__, __FUNCTION__, __LINE__, err, msg, __VA_ARGS__) ; \
}
Throw a Windows API error as an exception with a formatted description.
The result of the psystem::exception::system_exception::what() method will be something like "[error message]: [formatted msg]".
- Parameters
-
| err | The Windows API error code. |
| msg | The printf style format string. |
| ... | Arguments to populate the message given by msg. |
| std::string const psystem::exception::system_exception::m_what |
|
private |
The documentation for this class was generated from the following files: