summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrandomdan <randomdan@localhost>2010-12-21 14:54:47 +0000
committerrandomdan <randomdan@localhost>2010-12-21 14:54:47 +0000
commit61f6510dd017fc0f105ac070ec1891427afcedcb (patch)
tree17fe63cce421cb3cd12ac62e418e5dfaf2eb0aa4
parentDo some renaming and reorganising at last (diff)
downloadproject2-61f6510dd017fc0f105ac070ec1891427afcedcb.tar.bz2
project2-61f6510dd017fc0f105ac070ec1891427afcedcb.tar.xz
project2-61f6510dd017fc0f105ac070ec1891427afcedcb.zip
Catch Glib::Exceptions which don't inherit from std::exception (grr)
Use cxa_demangle to render the human readable exception class name Have other unhandled exceptions abort an FCGI process, which causes Apache to write a log of it
-rw-r--r--project2/cgi/p2webMain.cpp17
1 files changed, 16 insertions, 1 deletions
diff --git a/project2/cgi/p2webMain.cpp b/project2/cgi/p2webMain.cpp
index 25a4300..bce54fa 100644
--- a/project2/cgi/p2webMain.cpp
+++ b/project2/cgi/p2webMain.cpp
@@ -1,4 +1,5 @@
#include <libxml/tree.h>
+#include <glibmm/exception.h>
#include <cgicc/Cgicc.h>
#include <cgicc/CgiEnvironment.h>
#include <cgicc/HTTPContentHeader.h>
@@ -10,6 +11,7 @@ FILE * realstdout = stdout;
#include <boost/bind.hpp>
#include <syslog.h>
#include "FCgiIO.h"
+#include <cxxabi.h>
int
xmlWrite(void * _out, const char * buf, int len)
@@ -71,10 +73,22 @@ int main(void)
catch (const std::exception & e) {
cgicc::HTTPStatusHeader header(500, e.what());
header.render(IO);
+ char * buf = __cxxabiv1::__cxa_demangle(typeid(e).name(), NULL, NULL, NULL);
IO << "Kaboom!" << std::endl
<< std::endl
- << typeid(e).name() << std::endl
+ << buf << std::endl
<< e.what() << std::endl;
+ free(buf);
+ }
+ catch (const Glib::Exception & e) {
+ cgicc::HTTPStatusHeader header(500, e.what());
+ header.render(IO);
+ char * buf = __cxxabiv1::__cxa_demangle(typeid(e).name(), NULL, NULL, NULL);
+ IO << "Kaboom!" << std::endl
+ << std::endl
+ << buf << std::endl
+ << e.what() << std::endl;
+ free(buf);
}
catch (...) {
cgicc::HTTPStatusHeader header(500, "Unknown exception");
@@ -82,6 +96,7 @@ int main(void)
IO << "Kaboom!" << std::endl
<< std::endl
<< "Unknown exception." << std::endl;
+ throw;
}
alarm(60);
LoaderBase::onIteration();