diff options
author | randomdan <randomdan@localhost> | 2010-12-21 14:54:47 +0000 |
---|---|---|
committer | randomdan <randomdan@localhost> | 2010-12-21 14:54:47 +0000 |
commit | c8c7525471ba47c3a13f2d9ea56357016360f9a1 (patch) | |
tree | 17fe63cce421cb3cd12ac62e418e5dfaf2eb0aa4 | |
parent | Do some renaming and reorganising at last (diff) | |
download | project2-c8c7525471ba47c3a13f2d9ea56357016360f9a1.tar.bz2 project2-c8c7525471ba47c3a13f2d9ea56357016360f9a1.tar.xz project2-c8c7525471ba47c3a13f2d9ea56357016360f9a1.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.cpp | 17 |
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(); |