diff options
author | Pixel <pixel@nobis-crew.org> | 2011-11-21 13:27:53 -0800 |
---|---|---|
committer | Pixel <pixel@nobis-crew.org> | 2011-11-21 13:27:53 -0800 |
commit | e10639753d7dbd368f5edc2555d75c4b5905ba3b (patch) | |
tree | 34b6c4bc2990f48de30d26486426558d643e7ac8 /includes/Exceptions.h | |
parent | 071e7f07901309a38c8cb5311aaecaa46c0c3542 (diff) |
GeneralException() will now trace the callstack and store this, for debugging purposes.
Diffstat (limited to 'includes/Exceptions.h')
-rw-r--r-- | includes/Exceptions.h | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/includes/Exceptions.h b/includes/Exceptions.h index 0563090..c397265 100644 --- a/includes/Exceptions.h +++ b/includes/Exceptions.h @@ -3,22 +3,27 @@ #include <typeinfo> #include <cxxabi.h> #include <BString.h> +#include <vector> namespace Balau { class GeneralException { public: - GeneralException(const char * msg) : m_msg(::strdup(msg)) { } - GeneralException(const String & msg) : m_msg(msg.strdup()) { } - GeneralException(const GeneralException & e) : m_msg(strdup(e.m_msg)) { } + GeneralException(const char * msg) : m_msg(::strdup(msg)) { genTrace(); } + GeneralException(const String & msg) : m_msg(msg.strdup()) { genTrace(); } + GeneralException(const GeneralException & e) : m_msg(strdup(e.m_msg)), m_trace(e.m_trace) { } ~GeneralException() { if (m_msg) free(m_msg); } const char * getMsg() const { return m_msg; } + const std::vector<String> getTrace() const { return m_trace; } protected: GeneralException() : m_msg(0) { } void setMsg(char * msg) { if (m_msg) free(m_msg); m_msg = msg; } + void genTrace(); + private: char * m_msg; + std::vector<String> m_trace; }; static inline void * malloc(size_t size) throw (GeneralException) { |