#include <ddgerror.h>
Public Members | |||
enum | codes { Success, Failure, Memory, InitializationError, FileAccess, FileRead, FileWrite, FileContent, CommandArgUnknownOption, CommandArgMissingParameter, Render, Unknown, Warning } | ||
Define some useful error codes. | |||
ddgError (void) | |||
Constructor. | |||
~ddgError (void) | |||
Destructor. | |||
Static Public Members | |||
void | exitHandler ( void ) | ||
A function which will be called by the assert macros before exiting. | |||
bool | set (ddgErrorCode code, const char *msg, const char* filename, int line, const char *codeMsg = NULL) | ||
Set error, if msg is NULL, use the stream buffer. | |||
bool | isError (void) | ||
Check if an error is set. | |||
int | report (void) | ||
Dummy method. | |||
void | memory ( const char * file, unsigned int line, long size, long count, const char *type) | ||
Track memory usage. | |||
bool | reportMemory ( ddgStr *filename = NULL, char *s = NULL ) | ||
Report memory usage to logfile or standard out. More... | |||
unsigned long | reportTotalInUse (void) | ||
Report the current memory in used. | |||
unsigned long | reportMaxInUse (void) | ||
Report the maximum recorded memory in used upto this point. | |||
void | errorHandler ( void (*s)(ddgError *e)) | ||
Set the errorHandler function. |
In general methods should return false (ddgSuccess) if no error occured and true (ddgFailure) if there was an error. When an error occurs, the function should call Error::set and leave the message of what happened. At some point in the call stack the decision can be made to act on this error by calling Error::report or Error::exitHandler.
bool ddgError::reportMemory (ddgStr * filename = NULL, char * s = NULL) [static]
|
Report memory usage to logfile or standard out.
If s is specified this string is appended to the log file. Returns true if file could not be opened.