diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2018-02-10 15:40:46 +0000 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2018-03-03 00:39:17 +0000 |
commit | 9144f234f0cde55398d19696e42da8dea9c7bade (patch) | |
tree | 75a4541cefd744c5a299fa347a6d09c283318455 /icespider | |
parent | Add some nice cxxflags (diff) | |
download | icespider-9144f234f0cde55398d19696e42da8dea9c7bade.tar.bz2 icespider-9144f234f0cde55398d19696e42da8dea9c7bade.tar.xz icespider-9144f234f0cde55398d19696e42da8dea9c7bade.zip |
Default 500 error handler
Include the exception class name in the error report into the default
error page. Write the same output to the error log after the request
dump.
Diffstat (limited to 'icespider')
-rw-r--r-- | icespider/core/core.cpp | 7 | ||||
-rw-r--r-- | icespider/unittests/testApp.cpp | 2 |
2 files changed, 6 insertions, 3 deletions
diff --git a/icespider/core/core.cpp b/icespider/core/core.cpp index d63464e..057faa6 100644 --- a/icespider/core/core.cpp +++ b/icespider/core/core.cpp @@ -4,6 +4,7 @@ #include <Ice/ObjectAdapter.h> #include <boost/filesystem/convenience.hpp> #include <factory.impl.h> +#include <compileTimeFormatter.h> INSTANTIATEFACTORY(IceSpider::Plugin, Ice::CommunicatorPtr, Ice::PropertiesPtr); INSTANTIATEPLUGINOF(IceSpider::ErrorHandler); @@ -105,15 +106,17 @@ namespace IceSpider { defaultErrorReport(request, exception); } + AdHocFormatter(LogExp, "Exception type: %?\nDetail: %?\n"); void Core::defaultErrorReport(IHttpRequest * request, const std::exception & exception) const { char * buf = __cxxabiv1::__cxa_demangle(typeid(exception).name(), NULL, NULL, NULL); request->setHeader("Content-Type", "text/plain"); request->response(500, buf); - free(buf); - request->getOutputStream() << exception.what(); + LogExp::write(request->getOutputStream(), buf, exception.what()); request->dump(std::cerr); + LogExp::write(std::cerr, buf, exception.what()); + free(buf); } Ice::ObjectPrx diff --git a/icespider/unittests/testApp.cpp b/icespider/unittests/testApp.cpp index 5832595..9714d33 100644 --- a/icespider/unittests/testApp.cpp +++ b/icespider/unittests/testApp.cpp @@ -527,7 +527,7 @@ BOOST_AUTO_TEST_CASE( testErrorHandler_Unhandled ) BOOST_REQUIRE_EQUAL(h["Content-Type"], "text/plain"); auto & o = requestDeleteItem.output; auto b = o.str().substr(o.tellg()); - BOOST_REQUIRE_EQUAL(b, "test error"); + BOOST_REQUIRE_EQUAL(b, "Exception type: TestIceSpider::Ex\nDetail: test error\n"); } BOOST_AUTO_TEST_CASE( testErrorHandler_Handled1 ) |