CARMA C++
carma::util::SystemException Class Reference

Exception class for managing system errors. More...

#include "carma/util/BaseException.h"

Inheritance diagram for carma::util::SystemException:
carma::util::BaseException

Public Member Functions

virtual ::std::string getLogString () const
 
virtual const char * getSysMessage () const
 gets error message set within this instance. More...
 
SystemExceptionoperator= (const SystemException &rhs)
 
 SystemException (const SystemException &rhs)
 
 SystemException (const char *mesg, const char *sysMesg=strerror(errno), const char *fileName=__FILE__, const int lineNum=__LINE__)
 Constructor - creates an instance of class SystemException. More...
 
 SystemException (std::ostringstream &message, const char *sysMessage=strerror(errno), const char *fileName=__FILE__, const int lineNum=__LINE__)
 Constructor - creates an instance of class SystemException. More...
 
 SystemException (std::ostringstream &message, const std::ostringstream sysMessage=std::ostringstream(strerror(errno)), const char *fileName=__FILE__, const int lineNum=__LINE__)
 Constructor - creates an instance of class SystemException. More...
 
 SystemException (std::string &istring, const std::string sysMessage=strerror(errno), const char *fileName=__FILE__, const int lineNum=__LINE__)
 Constructor - creates an instance of class SystemException. More...
 
virtual ~SystemException () throw ( )
 Destructor for SystemException. More...
 
- Public Member Functions inherited from carma::util::BaseException
Backtrace getBacktrace () const
 
virtual int getLineNumber () const
 
virtual ::std::string getLogString () const
 
virtual const char * getMessage () const
 
virtual const char * getSourceFile () const
 
void logException (log4cpp::Priority::PriorityLevel priority) const
 
virtual void setMessageDirectly (const char *mesg)
 
virtual void setMessageToCopy (const char *mesg)
 
virtual void setMessageToCopy (const ::std::string &mesg)
 
virtual void setMessageToCopy (const ::std::ostringstream &oss)
 
virtual const char * what () const throw ( )
 
virtual ~BaseException () throw ( )
 

Additional Inherited Members

- Protected Member Functions inherited from carma::util::BaseException
 BaseException (const BaseException &rhs)
 
 BaseException (const char *mesg, const char *fileName, const int lineNo)
 Constructor - creates an instance of class BaseException. More...
 
 BaseException (const char *mesg, const ::std::string &fileName, const int lineNo)
 
 BaseException (const ::std::string &mesg, const char *fileName, const int lineNo)
 
 BaseException (const ::std::string &mesg, const ::std::string &fileName, const int lineNo)
 
 BaseException (const ::std::ostringstream &oss, const char *fileName, const int lineNo)
 
 BaseException (const ::std::ostringstream &oss, const ::std::string &fileName, const int lineNo)
 
BaseExceptionoperator= (const BaseException &rhs)
 
virtual void setLineNumber (int num)
 
void setSourceFileDirectly (const char *file)
 
void setSourceFileToCopy (const char *file)
 
void setSourceFileToCopy (const ::std::string &file)
 

Detailed Description

Exception class for managing system errors.

Class that automatically system error messages and provides facilities for logging error messages to a log4cpp logger.

Definition at line 46 of file SystemException.h.

Constructor & Destructor Documentation

carma::util::SystemException::SystemException ( const char *  mesg,
const char *  sysMesg = strerror(errno),
const char *  fileName = __FILE__,
const int  lineNum = __LINE__ 
)

Constructor - creates an instance of class SystemException.

Users should use the macro definition (see the #define towards the end of this file).

Parameters
mesgThe message to be logged for this exception. If the exception is to be caught outside the scope of the function where the exception was constructed, then 'mesg' should not be a stack variable. Stack variables are lost as the exception unwinds stacks on its way to the catcher.
sysMesgThe system error message to be logged for this exception. If the exception is to be caught outside the scope of the function where the exception was constructed, then 'sysMesg' should not be a stack variable. Stack variables are lost as the exception unwinds stacks on its way to the catcher.
fileNameThe source file containing the code throwing the exception - can be set using the cpp macro 'FILE'.
lineNumThe line number in the source file where the exception is created - should use the cpp macro 'LINE'.
Returns
none.
carma::util::SystemException::SystemException ( std::ostringstream &  message,
const char *  sysMessage = strerror(errno),
const char *  fileName = __FILE__,
const int  lineNum = __LINE__ 
)

Constructor - creates an instance of class SystemException.

Parameters
messageAn object of class ostringstream containing the message to be logged. If the exception is to be caught outside the scope of the function where the exception was constructed, then 'message' should not be a stack variable. Stack variables are lost as the exception unwinds stacks on its way to the catcher.
sysMessageThe system error message to be logged for this exception. If the exception is to be caught outside the scope of the function where the exception was constructed, then 'sysMesg' should not be a stack variable. Stack variables are lost as the exception unwinds stacks on its way to the catcher.
fileNameThe source file containing the code throwing the exception - can be set using the cpp macro 'FILE'.
lineNumThe line number in the source file where the exception is created - should use the cpp macro 'LINE'.
Returns
none.
carma::util::SystemException::SystemException ( std::ostringstream &  message,
const std::ostringstream  sysMessage = std::ostringstream(strerror(errno)),
const char *  fileName = __FILE__,
const int  lineNum = __LINE__ 
)

Constructor - creates an instance of class SystemException.

Parameters
messageAn object of class std::ostringstream containing the message to be logged. If the exception is to be caught outside the scope of the function where the exception was constructed, then 'message' should not be a stack variable. Stack variables are lost as the exception unwinds stacks on its way to the catcher.
sysMessageAn object of class ostringstream containing the system error message to be logged. If the exception is to be caught outside the scope of the function where the exception was constructed, then 'sysMessage' should not be a stack variable. Stack variables are lost as the exception unwinds stacks on its way to the catcher.
fileNameThe source file containing the code throwing the exception - can be set using the cpp macro 'FILE'.
lineNumThe line number in the source file where the exception is created - should use the cpp macro 'LINE'.
Returns
none.
carma::util::SystemException::SystemException ( std::string &  istring,
const std::string  sysMessage = strerror(errno),
const char *  fileName = __FILE__,
const int  lineNum = __LINE__ 
)

Constructor - creates an instance of class SystemException.

Parameters
istringAn object of class string containing the message to be logged. If the exception is to be caught outside the scope of the function where the exception was constructed, then 'istring' should not be a stack variable. Stack variables are lost as the exception unwinds stacks on its way to the catcher.
sysMessageAn object of class ostringstream containing the system error message to be logged. If the exception is to be caught outside the scope of the function where the exception was constructed, then 'sysMessage' should not be a stack variable. Stack variables are lost as the exception unwinds stacks on its way to the catcher.
fileNameThe source file containing the code throwing the exception - can be set using the cpp macro 'FILE'.
lineNumThe line number in the source file where the exception is created - should use the cpp macro 'LINE'.
Returns
none.
virtual carma::util::SystemException::~SystemException ( )
throw (
)
virtual

Destructor for SystemException.

Member Function Documentation

virtual const char* carma::util::SystemException::getSysMessage ( ) const
virtual

gets error message set within this instance.

getSysMessage - gets error message set within this instance of class SystemException. This message may be logged when the exception is caught. sysMesg__ is set using strerror( ) in the constructor.

Returns
error message as a constant char*.

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