summaryrefslogtreecommitdiff
path: root/includes
diff options
context:
space:
mode:
authorPixel <pixel@nobis-crew.org>2011-11-21 13:27:53 -0800
committerPixel <pixel@nobis-crew.org>2011-11-21 13:27:53 -0800
commite10639753d7dbd368f5edc2555d75c4b5905ba3b (patch)
tree34b6c4bc2990f48de30d26486426558d643e7ac8 /includes
parent071e7f07901309a38c8cb5311aaecaa46c0c3542 (diff)
GeneralException() will now trace the callstack and store this, for debugging purposes.
Diffstat (limited to 'includes')
-rw-r--r--includes/Exceptions.h11
-rw-r--r--includes/HttpServer.h2
-rw-r--r--includes/Main.h3
3 files changed, 12 insertions, 4 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) {
diff --git a/includes/HttpServer.h b/includes/HttpServer.h
index f78a816..51c119c 100644
--- a/includes/HttpServer.h
+++ b/includes/HttpServer.h
@@ -27,7 +27,7 @@ class HttpServer {
void unref() { if (Atomic::Decrement(&m_refCount) == 0) delete this; }
void ref() { Atomic::Increment(&m_refCount); }
void registerMe(HttpServer * server) { server->registerAction(this); }
- virtual bool Do(HttpServer * server, Http::Request & req, ActionMatch & match, IO<Handle> out) = 0;
+ virtual bool Do(HttpServer * server, Http::Request & req, ActionMatch & match, IO<Handle> out) throw (GeneralException) = 0;
private:
Regex m_regex, m_host;
volatile int m_refCount;
diff --git a/includes/Main.h b/includes/Main.h
index 5fa64c1..1c902ec 100644
--- a/includes/Main.h
+++ b/includes/Main.h
@@ -88,6 +88,9 @@ class Main {
catch (GeneralException e) {
m_status = STOPPING;
Printer::log(M_ERROR | M_ALERT, "The application caused an exception: %s", e.getMsg());
+ std::vector<String> trace = e.getTrace();
+ for (std::vector<String>::iterator i = trace.begin(); i != trace.end(); i++)
+ Printer::log(M_DEBUG, "%s", i->to_charp());
r = -1;
}
catch (...) {