An exception class that records where the exception was thrown and provides a stack trace. More...
#include <Errors.h>
Public Member Functions | |
ErrorMsg (const char *new_err_msg=NULL, const char *filename=NULL, int line_number=0) noexcept | |
The default constructor. More... | |
virtual const char * | GetError () const noexcept |
Provides the reason given for the error. More... | |
virtual const char * | GetType () const noexcept |
Provides the type of the exception if this is a subclass. More... | |
virtual bool | IsError (const char *test_err) const noexcept |
Return true if the the reason for the exception matches test_err. More... | |
virtual const char * | what () const noexcept |
Returns a full descriptive error message with reason, source location, and stack trace. More... | |
An exception class that records where the exception was thrown and provides a stack trace.
Use with the macro Throw_RC_Error("Reason"); to automatically pick up the source filename and line number. This exception should be used liberally any time an error would be informative for resolving a bug.
Stack tracing is implemented for Linux and Windows. For Linux with g++ or clang compile with -rdynamic for full symbols in the stack trace output from what(). For Windows symbols cannot be automatically provided with mingw, but the addresses provided in what() can be resolved by providing them as stdin to "addr2line -pfe myprogram.exe" for any program compiled with -ggdb.
|
inlinenoexcept |
The default constructor.
Use the convenience macro Throw_RC_Error("Reason"); which uses FILE and LINE to extract the location of the throw.
new_err_msg | The reason for the exception. |
filename | The source code file that the exception was triggered in. |
line_number | The source code line number that the exception was triggered on. |
|
inlinevirtualnoexcept |
Provides the reason given for the error.
|
inlinevirtualnoexcept |
Provides the type of the exception if this is a subclass.
An empty string is returned for the base class.
|
inlinevirtualnoexcept |
Return true if the the reason for the exception matches test_err.
test_err | An error message to compare with the reason given in the constructor. |
|
inlinevirtualnoexcept |
Returns a full descriptive error message with reason, source location, and stack trace.
Note: The stack trace is only available if on a supported system, and if the RC_NO_STACKTRACE option was not given in RCconfig.h