- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files
- Directories
- Examples

- Class List
- Class Hierarchy
- Class Members

Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Protected Attributes

# Error Class Reference

This reference page is linked to from the following overview topics: Displaying Messages and Progress Notifications.

Search for all occurrences

## Detailed Description

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:

     try
     {
         MyFunction();
     }
     catch( Error *pError )
     {
        // report the error to the user, and delete the object.
        pError->Report();
        ... do something here to handle the problem
     }

In MyFunction somewhere you can write:

     ...
     if ( pPointer == 0 )
         throw new Error( "No object specified" );
     ...

You should use the MB_ERROR macro to throw Errors:

     MB_ERROR( "No pointer specified in step %d", iStep );

See the macro MB_ERROR for more details.

Definition at line 46 of file error.h.

`#include <error.h>`

List of all members.

## 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.
Error * | Format (const QString &sMessage)
| Sets the message in the error.
enum Code | Code (void) const
| Returns the error code associated with the error.
const QString & | Message (void) const
| Returns the error message associated with the error.
void | Report (const QString &sPre="") const
| Reports the error to the user in a message box and deletes the Error object.
void | Discard (void) const
| Discards the error message and deletes the object (except s_cBadAlloc errors, which should never be deleted.)
## Static Public Member Functions
static void | ThrowBadAlloc (void)
| Throws a static bad alloc exception. (No memory allocation is required to report allocation problems.)
## 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

## Member Enumeration Documentation

enum Code

Search for all occurrences

Enumerator:

  codeOk | Search for all occurrences
  codeOutOfMemory | Search for all occurrences
  codeHardwareFailure | Search for all occurrences
  codeOutOfVideoMemory | Search for all occurrences
  codeUnspecified | Search for all occurrences
  codeUserSkip | Search for all occurrences
  codeUserIgnore | Search for all occurrences
  codeUserCancel | Search for all occurrences
  codeUnknown | Search for all occurrences

Definition at line 57 of file error.h.

        {
            codeOk,
            codeOutOfMemory,
            codeHardwareFailure,
            codeOutOfVideoMemory,
            codeUnspecified,
            codeUserSkip,
            codeUserIgnore,
            codeUserCancel,
            codeUnknown = 0xffffffff
        } m_eCode;

## Constructor & Destructor Documentation

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:

     throw new Error( "Some message" );

Parameters:

  [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)

## Member Function Documentation

Error* Format | ( | const QString & | sMessage | ) |

Search for all occurrences

Sets the message in the error.

Returns a pointer to itself.

enum Code Code | ( | void |  | ) | const

Search for all occurrences

Returns the error code associated with the error.

const QString& Message | ( | void |  | ) | const

Search for all occurrences

Returns the error message associated with the error.

void Report | ( | const QString & | sPre = `""` | ) | const

Search for all occurrences

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.)

Parameters:

  [in] | sPre | Optional string describing the pretext of the error

void Discard | ( | void |  | ) | const

Search for all occurrences

Discards the error message and deletes the object (except s_cBadAlloc errors, which should never be deleted.)

static void ThrowBadAlloc | ( | void |  | ) | `[inline, static]`

Search for all occurrences

Throws a static bad alloc exception. (No memory allocation is required to report allocation problems.)

Definition at line 112 of file error.h.

    { throw &s_cBadAlloc; };

## Member Data Documentation

QString m_sErrorMessage `[protected]`

Search for all occurrences

Definition at line 51 of file error.h.

bool m_bOnHeap `[protected]`

Search for all occurrences

Definition at line 52 of file error.h.

const char* m_pFunction `[protected]`

Search for all occurrences

Definition at line 53 of file error.h.

const char * m_pSource `[protected]`

Search for all occurrences

Definition at line 53 of file error.h.

unsigned int m_iLine `[protected]`

Search for all occurrences

Definition at line 54 of file error.h.

enum mudbox::Error::Code m_eCode

Search for all occurrences

Error s_cBadAlloc `[static]`

Search for all occurrences

Definition at line 112 of file error.h.

The documentation for this class was generated from the following file:

- Mudbox/error.h

Error Error Error Error Error Error Error Error Error Error
Error Error Error Error Error Error Error Error Error Error