14 #include "ExceptionLevel.hh"
18 namespace Exceptions {
43 std::string errorMessage,
44 std::string location)
throw();
52 const char*
what()
const throw() {
return &
_what[0]; }
68 inline void SetMessage(std::string new_message);
92 inline void SetWhat(std::string what_str);
109 _what = std::vector<char>(what_str.size()+1);
110 snprintf(&
_what[0], what_str.size()+1,
"%s", what_str.c_str());
const char * what() const
Return char buffer of message+" at "+location, memory remains owned by Exception. ...
Definition: Exception.hh:52
static void SetWillDoStackTrace(bool willDoStackTrace)
Set that it makes a stack trace on exception.
Definition: Exception.cc:40
void SetMessage(std::string new_message)
Set the error message.
Definition: Exception.hh:103
exceptionLevel GetErrorLevel() const
Get the severity of the exception.
Definition: Exception.hh:62
void SetWhat(std::string what_str)
Sets the reason for the exception.
Definition: Exception.hh:108
void Print()
Print the error message and location.
Definition: Exception.cc:33
std::string _message
Message to be thrown.
Definition: Exception.hh:96
Global exception object for all non-standard exceptions thrown by the code.
Definition: Exception.hh:30
static bool _willDoStackTrace
Returns the stack trace if true.
Definition: Exception.hh:95
std::string GetMessage() const
Get the error message (as defined by constructor)
Definition: Exception.hh:65
static bool GetWillDoStackTrace()
Return whether makes a stack trace on exception.
Definition: Exception.cc:44
~Exception()
Destructor.
Definition: Exception.hh:47
static const size_t _maxStackSize
Maximum memory size of the stack.
Definition: Exception.hh:94
std::string _location
Name of the function that threw.
Definition: Exception.hh:97
exceptionLevel
ExceptionLevel enumerates the severity of the exception.
Definition: ExceptionLevel.hh:16
std::string GetStackTrace() const
Return the stack trace if it was stored.
Definition: Exception.hh:74
std::string GetLocation() const
Get the location (as defined by Exception constructor) of the error.
Definition: Exception.hh:71
std::string _stacktrace
Stack trace as an std::string.
Definition: Exception.hh:98
std::vector< char > _what
Reason for throwing.
Definition: Exception.hh:99
exceptionLevel _level
Severity of the exception.
Definition: Exception.hh:100
static std::string MakeStackTrace(size_t skipTrace)
Gcc-specific code to recover the stack trace as a string.
Definition: Exception.cc:49
Exception()
Default constructor, initilizes everything to 0.
Definition: Exception.cc:14