1
0
Fork 0

improve Exceptionhandling

- add backtraces
  - derive public from std::exception so the usual catch to these kicks in.
This commit is contained in:
Willi Goesgens 2014-08-25 13:31:53 +02:00
parent 5bcc8d784f
commit e65a53475b
2 changed files with 18 additions and 1 deletions

View File

@ -51,6 +51,13 @@ TriagensError::TriagensError (string const& type, string const& details, char co
if (! details.empty()) { if (! details.empty()) {
_message += " details = '" + _details + "'"; _message += " details = '" + _details + "'";
} }
#ifdef TRI_ENABLE_MAINTAINER_MODE
#if HAVE_BACKTRACE
_backtrace();
#endif
#endif
} }

View File

@ -285,12 +285,22 @@ namespace triagens {
/// @brief JsonException, an exception class for the Json class /// @brief JsonException, an exception class for the Json class
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
class JsonException : std::exception { class JsonException : public virtual std::exception {
std::string _msg; std::string _msg;
public: public:
JsonException () : _msg("Json exception") { JsonException () : _msg("Json exception") {
#ifdef TRI_ENABLE_MAINTAINER_MODE
#if HAVE_BACKTRACE
_backtrace();
#endif
#endif
} }
JsonException (string msg) : _msg(msg) { JsonException (string msg) : _msg(msg) {
#ifdef TRI_ENABLE_MAINTAINER_MODE
#if HAVE_BACKTRACE
_backtrace();
#endif
#endif
} }
char const* what () const throw() { char const* what () const throw() {
return _msg.c_str(); return _msg.c_str();