fix a potential segfault in the Lumiera exception base class

This commit is contained in:
Fischlurch 2008-12-07 06:28:26 +01:00 committed by Christian Thaeter
parent 20c719d89c
commit f0fd9dd1ae

View file

@ -41,12 +41,19 @@ namespace lumiera {
* catch clauses.
* @todo to be localised
*/
inline const string default_usermsg (Error* exception_obj) throw()
inline const string
default_usermsg (Error* exception_obj) throw()
{
return string("Sorry, Lumiera encountered an internal error. (")
+ typeid(*exception_obj).name() + ")";
}
inline const char*
default_or_given (const char* id)
{
return id? id : LUMIERA_ERROR_STATE;
}
/* constants to be used as error IDs */
LUMIERA_ERROR_DEFINE (LOGIC , "internal logic broken");
@ -67,7 +74,7 @@ namespace lumiera {
/** @note we set the C-style errorstate as a side effect */
Error::Error (string description, const char* id) throw()
: std::exception (),
id_ (id),
id_ (default_or_given (id)),
msg_ (error::default_usermsg (this)),
desc_ (description),
cause_ ("")
@ -79,7 +86,7 @@ namespace lumiera {
Error::Error (std::exception& cause,
string description, const char* id) throw()
: std::exception (),
id_ (id),
id_ (default_or_given (id)),
msg_ (error::default_usermsg (this)),
desc_ (description),
cause_ (extractCauseMsg(cause))