From c8c7525471ba47c3a13f2d9ea56357016360f9a1 Mon Sep 17 00:00:00 2001 From: randomdan Date: Tue, 21 Dec 2010 14:54:47 +0000 Subject: 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 --- project2/cgi/p2webMain.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) 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 +#include #include #include #include @@ -10,6 +11,7 @@ FILE * realstdout = stdout; #include #include #include "FCgiIO.h" +#include 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(); -- cgit v1.2.3