#include <Error.hpp>
Public Types | |
typedef std::map< std::string, boost::any > | Context |
Public Member Functions | |
Error (MessageId inId, const Context &inContext, const std::string &inFunction, const std::string &inFile, uint32_t inLine) | |
Error (MessageId inId, const std::string &inFunction, const std::string &inFile, uint32_t inLine) | |
Error (const Error &source) throw () | |
Error & | operator= (const Error &source) throw () |
const std::vector < StackFrameInfo > & | getStackTrace () const throw () |
void | setCurrentLocation (const std::string &inFunction, const std::string &inFile, uint32_t inLine) throw () |
const Context | getContextData () const throw () |
void | saveContextData (const std::string &inName, const boost::any &inSource) throw () |
const MessageId | getErrorMessageId () const throw () |
Private Attributes | |
std::vector< StackFrameInfo > | mStackTrace |
Context | mContextData |
MessageId | mErrorMessageId |
Classes | |
struct | StackFrameInfo |
The Error class is used to convey exception information to the user. The error object is constructed by the throwing method and propagated upwards by the calling functions.
Definition at line 40 of file Error.hpp.
typedef std::map< std::string, boost::any > torc::generic::Error::Context |
torc::generic::Error::Error | ( | MessageId | inId, | |
const Context & | inContext, | |||
const std::string & | inFunction, | |||
const std::string & | inFile, | |||
uint32_t | inLine | |||
) |
Constructor.
[in] | inId | Error message identifier that can be used to look up the message in MessageTable. |
[in] | inContext | Context data that will be saved inside this error object. |
[in] | inFunction | Function name from where this exception is being thrown. This will typically be set to __FUNCTION__. |
[in] | inFile | File name from where this exception is being thrown. This will typically be set to __FILE__. |
[in] | inLine | Line No. in the file from where this exception is being thrown. This will typically be set to __LINE__. |
torc::generic::Error::Error | ( | MessageId | inId, | |
const std::string & | inFunction, | |||
const std::string & | inFile, | |||
uint32_t | inLine | |||
) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
const std::vector< Error::StackFrameInfo > & torc::generic::Error::getStackTrace | ( | ) | const throw () [inline] |
void torc::generic::Error::setCurrentLocation | ( | const std::string & | inFunction, | |
const std::string & | inFile, | |||
uint32_t | inLine | |||
) | throw () |
Set the current location. This method should be used by catching contexts to push location data into the error object.
[in] | inFunction | Function name from where this exception is being thrown. This will typically be set to __FUNCTION__. |
[in] | inFile | File name from where this exception is being thrown. This will typically be set to __FILE__. |
[in] | inLine | Line No. in the file from where this exception is being thrown. This will typically be set to __LINE__. |
const Error::Context torc::generic::Error::getContextData | ( | ) | const throw () [inline] |
Get the map of context data for this exception. This can be looked up by interested parties for context sensitive information. Note that the value_type for this map is boost::any and therefore an appropriate boost::any_cast is required to get the actual data.
void torc::generic::Error::saveContextData | ( | const std::string & | inName, | |
const boost::any & | inSource | |||
) | throw () |
Save a context sensitive data with a meaningful name, that can be retreived by interested catching contexts.
[in] | inName | Name of the data. |
[in] | inSource | Any type of data. The only restrictions are that the type of data should be copy constructible and assignable. |
const MessageId torc::generic::Error::getErrorMessageId | ( | ) | const throw () [inline] |