torc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
torc::generic::Error Class Reference

The Error object thrown by different methods of EdifOM. More...

#include <Error.hpp>

Data Structures

struct  StackFrameInfo
 

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 () throw ()
 
 Error (const Error &source)
 
Erroroperator= (const Error &source)
 
const std::vector
< StackFrameInfo > & 
getStackTrace () const
 
void setCurrentLocation (const std::string &inFunction, const std::string &inFile, uint32_t inLine)
 
const Context getContextData () const
 
void saveContextData (const std::string &inName, const boost::any &inSource)
 
const MessageId getErrorMessageId () const
 

Private Attributes

std::vector< StackFrameInfomStackTrace
 
Context mContextData
 
MessageId mErrorMessageId
 

Detailed Description

The Error object thrown by different methods of EdifOM.

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.

Note
This class does not inherit from std::exception by design. Clients should keep that in mind while using this class.

Definition at line 41 of file Error.hpp.

Member Typedef Documentation

typedef std::map<std::string, boost::any> torc::generic::Error::Context

Context sensitive data for the error object. The Context map stores a boost::any inSource corresponding to a name. As the Error bubbles up, this data may be augmented by catching contexts.

Definition at line 48 of file Error.hpp.

Constructor & Destructor Documentation

torc::generic::Error::Error ( MessageId  inId,
const Context inContext,
const std::string &  inFunction,
const std::string &  inFile,
uint32_t  inLine 
)

Constructor.

Parameters
[in]inIdError message identifier that can be used to look up the message in MessageTable.
[in]inContextContext data that will be saved inside this error object.
[in]inFunctionFunction name from where this exception is being thrown. This will typically be set to FUNCTION.
[in]inFileFile name from where this exception is being thrown. This will typically be set to FILE.
[in]inLineLine No. in the file from where this exception is being thrown. This will typically be set to LINE.

Definition at line 42 of file Error.cpp.

43  : mStackTrace(), mContextData(inContext),
44  mErrorMessageId(inId) {
45  StackFrameInfo info(inFunction, inFile, inLine);
46  mStackTrace.push_back(info);
47 }
MessageId mErrorMessageId
Definition: Error.hpp:155
Context mContextData
Definition: Error.hpp:154
std::vector< StackFrameInfo > mStackTrace
Definition: Error.hpp:153
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.

Definition at line 52 of file Error.cpp.

53  :
55  StackFrameInfo info(inFunction, inFile, inLine);
56  mStackTrace.push_back(info);
57 }
MessageId mErrorMessageId
Definition: Error.hpp:155
Context mContextData
Definition: Error.hpp:154
std::vector< StackFrameInfo > mStackTrace
Definition: Error.hpp:153
torc::generic::Error::~Error ( )
throw (
)

Definition at line 59 of file Error.cpp.

59 {}
torc::generic::Error::Error ( const Error source)

Definition at line 61 of file Error.cpp.

61  : mStackTrace(source.mStackTrace),
62  mContextData(source.mContextData), mErrorMessageId(source.mErrorMessageId) {}
MessageId mErrorMessageId
Definition: Error.hpp:155
Context mContextData
Definition: Error.hpp:154
std::vector< StackFrameInfo > mStackTrace
Definition: Error.hpp:153

Member Function Documentation

const Error::Context torc::generic::Error::getContextData ( ) const
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.

Returns
const reference to a Context object.

Definition at line 186 of file Error.hpp.

186  {
187  return mContextData;
188 }
Context mContextData
Definition: Error.hpp:154
const MessageId torc::generic::Error::getErrorMessageId ( ) const
inline

Get the error message Id for this error.

Returns
MessageId corresponding to this error

Definition at line 195 of file Error.hpp.

195  {
196  return mErrorMessageId;
197 }
MessageId mErrorMessageId
Definition: Error.hpp:155

+ Here is the caller graph for this function:

const std::vector< Error::StackFrameInfo > & torc::generic::Error::getStackTrace ( ) const
inline

Get the complete stack trace.

Returns
vector containing the StackFrameInfo objects.

Definition at line 175 of file Error.hpp.

175  {
176  return mStackTrace;
177 }
std::vector< StackFrameInfo > mStackTrace
Definition: Error.hpp:153

+ Here is the caller graph for this function:

Error & torc::generic::Error::operator= ( const Error source)

Definition at line 64 of file Error.cpp.

64  {
65  if(this != &source) {
66  mStackTrace = source.mStackTrace;
67  mContextData = source.mContextData;
68  mErrorMessageId = source.mErrorMessageId;
69  }
70  return *this;
71 }
MessageId mErrorMessageId
Definition: Error.hpp:155
Context mContextData
Definition: Error.hpp:154
std::vector< StackFrameInfo > mStackTrace
Definition: Error.hpp:153
void torc::generic::Error::saveContextData ( const std::string &  inName,
const boost::any &  inSource 
)

Save a context sensitive data with a meaningful name, that can be retreived by interested catching contexts.

Parameters
[in]inNameName of the data.
[in]inSourceAny type of data. The only restrictions are that the type of data should be copy constructible and assignable.

Definition at line 79 of file Error.cpp.

79  {
80  mContextData[inName] = inSource;
81 }
Context mContextData
Definition: Error.hpp:154
void torc::generic::Error::setCurrentLocation ( const std::string &  inFunction,
const std::string &  inFile,
uint32_t  inLine 
)

Set the current location. This method should be used by catching contexts to push location data into the error object.

Parameters
[in]inFunctionFunction name from where this exception is being thrown. This will typically be set to FUNCTION.
[in]inFileFile name from where this exception is being thrown. This will typically be set to FILE.
[in]inLineLine No. in the file from where this exception is being thrown. This will typically be set to LINE.

Definition at line 73 of file Error.cpp.

74  {
75  StackFrameInfo info(inFunction, inFile, inLine);
76  mStackTrace.push_back(info);
77 }
std::vector< StackFrameInfo > mStackTrace
Definition: Error.hpp:153

Field Documentation

Context torc::generic::Error::mContextData
private

Definition at line 154 of file Error.hpp.

MessageId torc::generic::Error::mErrorMessageId
private

Definition at line 155 of file Error.hpp.

std::vector<StackFrameInfo> torc::generic::Error::mStackTrace
private

Definition at line 153 of file Error.hpp.


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