Base exception class for managing carma errors.
More...
#include <carma/util/BaseException.h>
|
| 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) |
|
BaseException & | operator= (const BaseException &rhs) |
|
virtual void | setLineNumber (int num) |
|
void | setSourceFileDirectly (const char *file) |
|
void | setSourceFileToCopy (const char *file) |
|
void | setSourceFileToCopy (const ::std::string &file) |
|
|
(Note that these are not member functions.)
|
std::ostream & | operator<< (::std::ostream &os, const ::std::exception &error) |
| Insert (i.e. output) the error message from any ::std::exception into an output stream. More...
|
|
Base exception class for managing carma errors.
Includes facilities for specifying and logging error messages to a default process wide carma logger.
Definition at line 48 of file BaseException.h.
virtual carma::util::BaseException::~BaseException |
( |
| ) |
|
throw | ( | |
| ) | | |
|
virtual |
carma::util::BaseException::BaseException |
( |
const char * |
mesg, |
|
|
const char * |
fileName, |
|
|
const int |
lineNo |
|
) |
| |
|
protected |
Constructor - creates an instance of class BaseException.
Users should use the macro definition (see the #define towards the end of this file).
- Parameters
-
mesg | The 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. |
fileName | The source file containing the code throwing the exception - can be set using the cpp macro 'FILE'. |
lineNo | The line number in the source file where the exception is created - should use the cpp macro 'LINE'. |
- Returns
- none.
virtual int carma::util::BaseException::getLineNumber |
( |
| ) |
const |
|
virtual |
getLineNumber - gets the number of the line within the source file where the exception was created. Intended to be used as a means of recording the location where the exception was thrown. This line number is set as a parameter in the public constructor - should use the cpp macro 'LINE'.
- Returns
- line number as an integer.
virtual const char* carma::util::BaseException::getMessage |
( |
| ) |
const |
|
virtual |
getMessage - gets error message set within this instance of class BaseException. This message may be logged when the exception is caught. BaseException::setMessage is used to set the message.
- Returns
- error message as a constant char*.
virtual const char* carma::util::BaseException::getSourceFile |
( |
| ) |
const |
|
virtual |
getSourceFile - gets the name of the source file where this exception was created. Intended to be used as a means of recording the location where the exception was thrown. The name of the source file is set as a parameter in the public constructor - should use the cpp macro 'FILE'.
- Returns
- source file name as a constant char*.
void carma::util::BaseException::logException |
( |
log4cpp::Priority::PriorityLevel |
priority | ) |
const |
logException - logs the message associated with this instance of BaseException. Message is logged with the source file name and line number of the location where this exception was constructed. The message is logged using the carma::util::Logger associated with the current process.
- Parameters
-
priority | Priority of the message to be logged, as a variable of type log4cpp::Priority. |
- Returns
- none.
virtual void carma::util::BaseException::setLineNumber |
( |
int |
num | ) |
|
|
protectedvirtual |
setLineNumber - gets the number of the line within the source file where the exception was created. Intended to be used as a means of recording the location where the exception was thrown. This line number is set as a parameter in the public constructor - should use the cpp macro 'LINE'.
virtual void carma::util::BaseException::setMessageDirectly |
( |
const char * |
mesg | ) |
|
|
virtual |
setMessage - sets error message within this instance of class BaseException. This message may be logged when the exception is caught. BaseException::getMessage also returns the message. setMessage does not make a local copy of the string as we want to minimize the potential for exceptions generated by operations in BaseException.
- Parameters
-
mesg | The message to be logged for this exception. |
- Returns
- none.
virtual void carma::util::BaseException::setMessageToCopy |
( |
const ::std::string & |
mesg | ) |
|
|
virtual |
setMessage - sets error message within this instance of class BaseException. This message may be logged when the exception is caught. BaseException::getMessage also returns the message.
- Parameters
-
istring | A string containing the message to be logged for this exception. |
- Returns
- none.
virtual void carma::util::BaseException::setMessageToCopy |
( |
const ::std::ostringstream & |
oss | ) |
|
|
virtual |
setMessage - sets error message within this instance of class BaseException. This message may be logged when the exception is caught. BaseException::getMessage also returns the message.
- Parameters
-
stream | A stream containing the message to be logged for this exception. |
- Returns
- none.
void carma::util::BaseException::setSourceFileDirectly |
( |
const char * |
file | ) |
|
|
protected |
setSourceFile - gets the name of the source file where this exception was created. Intended to be used as a means of recording the location where the exception was thrown. The name of the source file is set as a parameter in the public constructor - should use the cpp macro 'FILE'.
- Returns
- source file name as a constant char*.
virtual const char* carma::util::BaseException::what |
( |
| ) |
const |
throw | ( | |
| ) | | |
|
virtual |
what - returns full text of message to be logged. BaseException.
- Todo:
- Must complete this function. For now, just returns message set using setMessage, or constructor. Must instead return string(?) with full text.
- Returns
- full text of error message as const char*.
- Exceptions
-
undefined | exception thrown - required for compatibility with std::exception. |
Reimplemented in carma::antenna::bima::SharedMemoryException, and carma::util::ErrorException.
std::ostream & operator<< |
( |
::std::ostream & |
os, |
|
|
const ::std::exception & |
error |
|
) |
| |
|
related |
Insert (i.e. output) the error message from any ::std::exception into an output stream.
Typical usage is like so:
* ::std::cout << myStdException << ::std::endl;
*
- Parameters
-
os | The output stream to insert the message into. |
error | The exception to get the message from. |
- Returns
- The
os
output stream parameter so that stream insertions can be chained in the usual C++ way (as shown in the example).
The documentation for this class was generated from the following files: