iError Project Site at SourceForge.net Logo
Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

iERR::iErrorHandler Class Reference

The base class for error handlers. More...

#include <iError.h>

Inheritance diagram for iERR::iErrorHandler::

iERR::iStdErrorHandler List of all members.

Public Methods

 iErrorHandler ()
 constructor. More...

virtual ~iErrorHandler ()
 destructor. More...

virtual int Throw (iError::ErrorLevel errLevel, const char *functionName, const char *file, int line, iErrorCode *errCode,...)
 Use this method to create error and evtl to throw it as C++ exception. More...

virtual bool Rethrow (const char *functionName=NULL, const char *file=NULL, int line=0)
 Use this method to propagate the error or use iRethrow macro to call Rethrow of the current error handler. More...

virtual bool Handle (const char *functionName=NULL, const char *file=NULL, int line=0)
 Display the last error occured, write it to a log file or whatever the error handler desires to do with it. More...

virtual bool Reset ()
 Use this method to reset the last error, so iLastError will return NULL. More...

virtual iErrorLastError (bool reset=false)
 Returns the last error occured. More...

iErrorHandler * SetCurrent ()
 Set this error handler to be the current error handler. More...


Static Public Methods

iErrorHandler * Current ()
 Get the current error handler. More...


Protected Methods

virtual void _Throw ()=0
 overload this method to provide customized error throwing. More...

virtual void _Handle ()=0
 overload this method to provide customized error handling. More...


Protected Attributes

iErrorm_Last
 @label pointer to m_LastError or NULL. More...


Private Attributes

iErrorm_LastError
 The error handlers own iError instance @label m_LastError. More...


Static Private Attributes

int m_HandlerCount = 0
 Used for thread local storage initialisation. More...


Friends

class iError

Detailed Description

The base class for error handlers.

To handle an error use an instance of the concrete error handler or the current error handler (iErrorHandler::Current). Use iThrow macro to do it automaticly

Definition at line 410 of file iError.h.


Constructor & Destructor Documentation

iERR::iErrorHandler::iErrorHandler  
 

constructor.

Definition at line 62 of file iError.cpp.

References iError, m_HandlerCount, and m_LastError.

Referenced by Current(), and SetCurrent().

iERR::iErrorHandler::~iErrorHandler   [virtual]
 

destructor.

Definition at line 81 of file iError.cpp.

References m_HandlerCount, and m_LastError.


Member Function Documentation

virtual void iERR::iErrorHandler::_Handle   [protected, pure virtual]
 

overload this method to provide customized error handling.

Reimplemented in iERR::iStdErrorHandler.

Referenced by Handle().

virtual void iERR::iErrorHandler::_Throw   [protected, pure virtual]
 

overload this method to provide customized error throwing.

Reimplemented in iERR::iStdErrorHandler.

Referenced by Rethrow(), and Throw().

iErrorHandler * iERR::iErrorHandler::Current   [static]
 

Get the current error handler.

Definition at line 242 of file iError.cpp.

References iErrorHandler().

bool iERR::iErrorHandler::Handle const char *    functionName = NULL,
const char *    file = NULL,
int    line = 0
[virtual]
 

Display the last error occured, write it to a log file or whatever the error handler desires to do with it.

If HERE macro is used as parameter, the debug information of the error is replaced with the file name and line number of the caller.

Returns:
true if an error was handled, false if there were no errors to handle.
Parameters:
file  the filename, where the error is handled
line  the line where the error is handled

Definition at line 194 of file iError.cpp.

References _Handle(), and m_Last.

Referenced by iERR::iStdErrorHandler::_Throw().

iError * iERR::iErrorHandler::LastError bool    reset = false [virtual]
 

Returns the last error occured.

Parameters:
reset  if true the last error is reset to NULL, if false the subsequent calls to Last() are possible
If an error occurs in a function, that have a return type, the function will throw an iError and return the NULL value. The iError instance is stored internal by iErrorHandler class and may be retrived by the LastError() method. If no error occured, NULL is returned.

Definition at line 233 of file iError.cpp.

References iError, m_Last, and Reset().

Referenced by iERR::iStdErrorHandler::_Throw().

bool iERR::iErrorHandler::Reset   [virtual]
 

Use this method to reset the last error, so iLastError will return NULL.

Returns:
true if there were an unhandled error, false if there were no errors.

Definition at line 220 of file iError.cpp.

References m_Last.

Referenced by LastError().

bool iERR::iErrorHandler::Rethrow const char *    functionName = NULL,
const char *    file = NULL,
int    line = 0
[virtual]
 

Use this method to propagate the error or use iRethrow macro to call Rethrow of the current error handler.

If HERE macro is used as parameter, the debug information of the error is replaced with the file name and line number of the caller.

Returns:
true if an error was rethrown, false if there were no errors.
Parameters:
file  the filename, where the error occured
line  the line where the error occured example: if (iRethrow(HERE)) return;

Definition at line 169 of file iError.cpp.

References _Throw(), and m_Last.

iErrorHandler * iERR::iErrorHandler::SetCurrent  
 

Set this error handler to be the current error handler.

Returns:
old error handler.

Definition at line 277 of file iError.cpp.

References iErrorHandler().

int iERR::iErrorHandler::Throw iError::ErrorLevel    errLevel,
const char *    functionName,
const char *    fileName,
int    lineNr,
iErrorCode   errCode,
...   
[virtual]
 

Use this method to create error and evtl to throw it as C++ exception.

Or use iThrow macro to call Throw of the current error handler. Use INFO, WARNING, CRITICAL or EXCEPTION macros instead of specifying parameters The default error handler will only throw the error as C++ exception if the error level is iEXCEPTION. Use Handle() to display the last error or whatever the error handler will do with it.

Parameters:
errLevel  iINFO, iWARNING, iCRITICAL or iEXCEPTION
file  the filename, where the error occured
line  the line where the error occured
errCode  the type of error
...  the description parameters according to the errCode description
Returns:
the error code as integer as defined by errCode object example: iThrow(WARNING(OBJ_NOT_FOUND), "obj name");

Definition at line 99 of file iError.cpp.

References _Throw(), m_Last, and m_LastError.


Friends And Related Function Documentation

friend class iError [friend]
 

Definition at line 413 of file iError.h.

Referenced by iErrorHandler(), and LastError().


Member Data Documentation

int iERR::iErrorHandler::m_HandlerCount = 0 [static, private]
 

Used for thread local storage initialisation.

Definition at line 46 of file iError.cpp.

Referenced by iErrorHandler(), and ~iErrorHandler().

iError* iERR::iErrorHandler::m_Last [protected]
 

@label pointer to m_LastError or NULL.

See also:
LastError()

Definition at line 528 of file iError.h.

Referenced by iERR::iStdErrorHandler::_Handle(), iERR::iStdErrorHandler::_Throw(), Handle(), LastError(), Reset(), Rethrow(), and Throw().

iError* iERR::iErrorHandler::m_LastError [private]
 

The error handlers own iError instance @label m_LastError.

Definition at line 536 of file iError.h.

Referenced by iErrorHandler(), Throw(), and ~iErrorHandler().


The documentation for this class was generated from the following files:
© 2002 by C-LAB
generated by doxygen