#include <error.h>
Holds information about an error.
Typically heap allocated.
Objects of this class are usually created on the heap and used in exception handling in the following way:
In MyFunction somewhere you can write:
You should use the MB_ERROR macro to throw Errors:
See the macro MB_ERROR for more details.
Public Types | |
enum | Code { codeOk, codeOutOfMemory, codeHardwareFailure, codeOutOfVideoMemory, codeUnspecified, codeUserSkip, codeUserIgnore, codeUserCancel, codeUnknown = 0xffffffff } |
Public Member Functions | |
Error (const QString &sMessage, Code eCode=codeUnspecified, const char *pFunction=0, const char *pSourceFileName=0, unsigned int iLine=0) | |
Constructor. More... | |
Error * | Format (const QString &sMessage) |
Sets the message in the error. More... | |
enum Code | Code (void) const |
Returns the error code associated with the error. More... | |
const QString & | Message (void) const |
Returns the error message associated with the error. More... | |
void | Report (const QString &sPre="") const |
Reports the error to the user in a message box and deletes the Error object. More... | |
void | Discard (void) const |
Discards the error message and deletes the object (except s_cBadAlloc errors, which should never be deleted.) More... | |
Static Public Member Functions | |
static void | ThrowBadAlloc (void) |
Throws a static bad alloc exception. (No memory allocation is required to report allocation problems.) More... | |
Public Attributes | |
enum mudbox::Error::Code | m_eCode |
Static Public Attributes | |
static Error | s_cBadAlloc |
Protected Attributes | |
QString | m_sErrorMessage |
bool | m_bOnHeap |
const char * | m_pFunction |
const char * | m_pSource |
unsigned int | m_iLine |
enum Code |
Enumerator | |
---|---|
codeOk | |
codeOutOfMemory | |
codeHardwareFailure | |
codeOutOfVideoMemory | |
codeUnspecified | |
codeUserSkip | |
codeUserIgnore | |
codeUserCancel | |
codeUnknown |
Definition at line 57 of file error.h.
Error | ( | const QString & | sMessage, |
Code | eCode = codeUnspecified , |
||
const char * | pFunction = 0 , |
||
const char * | pSourceFileName = 0 , |
||
unsigned int | iLine = 0 |
||
) |
Constructor.
How this is usually used:
[in] | sMessage | Message that explains the error |
[in] | eCode | Error code (optional) |
[in] | pFunction | Name of the function where the error happens (optional) |
[in] | pSourceFileName | Name of the source files where the error happens (optional) |
[in] | iLine | Line number in the source file where the error happens (optional) |
Sets the message in the error.
Returns a pointer to itself.
Reports the error to the user in a message box and deletes the Error object.
Errors are written into the log file, and also reported in a message box that the user must dismiss. If you specify a pretext string, it will be displayed first. After reporting is complete, the Error object will be deleted in this call (except s_cBadAlloc errors, which don't reside in deletable space.)
[in] | sPre | Optional string describing the pretext of the error |
Discards the error message and deletes the object (except s_cBadAlloc errors, which should never be deleted.)
enum mudbox::Error::Code m_eCode |