lumiera::Error Class Reference

Interface and Baseclass of all Exceptions thrown from within Lumiera (C++) code. More...

#include <error.hpp>

Collaboration diagram for lumiera::Error:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 Error (const Error &) throw ()
 Error (std::exception &cause, string description="", const char *id=LUMIERA_ERROR_EXCEPTION) throw ()
 Error (string description="", const char *id=LUMIERA_ERROR_EXCEPTION) throw ()
const char * getID () const throw ()
 the internal Lumiera-error-ID (was set as C-errorstate in ctor)
const string & getUsermsg () const throw ()
 extract the message to be displayed for the user
ErrorprependInfo (const string &text) throw ()
 give additional developer info.
const string & rootCause () const throw ()
 If this exception was caused by a chain of further exceptions, return the description of the first one registered in this throw sequence.
ErrorsetUsermsg (const string &newMsg) throw ()
 replace the previous or default friendly message for the user.
virtual const char * what () const throw ()
 yield a diagnostic message characterizing the problem

Static Private Member Functions

static const string extractCauseMsg (const std::exception &) throw ()

Private Attributes

const string cause_
 descriptoin of first exception encountered in the chain
string desc_
 detailed description of the error situation for the developers
const char * id_
 an LUMIERA_ERROR id, which is set as errorstate on construction
string msg_
 friendly message intended for users (to be localized)
string what_
 buffer for generating the detailed description on demand


Detailed Description

Common operations for getting an diagnostic message and for obtaining the root cause, i.e. the first exception encountered in a chain of exceptions.

Definition at line 48 of file error.hpp.


Constructor & Destructor Documentation

lumiera::Error::Error ( string  description = "",
const char *  id = LUMIERA_ERROR_EXCEPTION 
) throw ()

Note:
we set the C-style errorstate as a side effect

Definition at line 71 of file error.cpp.

References lumiera_error_set().

00072     : std::exception (),
00073       id_ (id),
00074       msg_ (error::default_usermsg (this)),
00075       desc_ (description),
00076       cause_ ("")
00077   {
00078     lumiera_error_set (this->id_);
00079   }

Here is the call graph for this function:

lumiera::Error::Error ( const Error ref  )  throw ()

Note:
copy ctor behaves like chaining, i.e setting the cause_.

Definition at line 95 of file error.cpp.

00096     : std::exception (),
00097       id_ (ref.id_),
00098       msg_ (ref.msg_),
00099       desc_ (ref.desc_),
00100       cause_ (extractCauseMsg(ref))
00101   { }


Member Function Documentation

Error& lumiera::Error::prependInfo ( const string &  text  )  throw () [inline]

Typically used at intermediate handlers to add context.

Definition at line 79 of file error.hpp.

References desc_.

00079 { this->desc_.insert (0,text); return *this; }

const string& lumiera::Error::rootCause (  )  const throw () [inline]

This works only if every exceptions thrown as a consequence of another exception is propperly constructed by passing the original exception to the constructor

Returns:
the description string, maybe empty (if there is no known root cause)

Definition at line 73 of file error.hpp.

References cause_.

00073 { return this->cause_; }

Error& lumiera::Error::setUsermsg ( const string &  newMsg  )  throw () [inline]

To be localized.

Definition at line 76 of file error.hpp.

References msg_.

00076 { this->msg_ = newMsg; return *this; }

const char * lumiera::Error::what (  )  const throw () [virtual]

Description of the problem, including the internal char constant in accordance to Lumiera's error identification scheme.

If a root cause can be obtained, this will be included in the generated output as well.

Definition at line 111 of file error.cpp.

References cause_, desc_, id_, and what_.

Referenced by asset::DB::clear().

00112   {
00113     if (isnil (this->what_))
00114       {
00115         what_ = string(id_);
00116         if (!isnil (desc_))  what_ += " ("+desc_+").";
00117         if (!isnil (cause_)) what_ += string(" -- caused by: ") + cause_;
00118       }
00119     return what_.c_str(); 
00120   }

Here is the caller graph for this function:


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

Generated on Sat Aug 16 18:10:42 2008 for Lumiera by  doxygen 1.5.5