2 #define TRACE_NAME "ExceptionHandler"
3 #include "ExceptionHandler.hh"
4 #include "ExceptionStackTrace.hh"
6 #include "canvas/Utilities/Exception.h"
7 #include "cetlib_except/exception.h"
10 #include <boost/exception/all.hpp>
13 #ifdef EXCEPTIONSTACKTRACE
21 std::string::size_type pos = 0;
22 std::string::size_type prev = 0;
24 while ((pos = message.find(
'\n', prev)) != std::string::npos)
26 TLOG(TLVL_DEBUG) << message.substr(prev, pos - prev);
30 TLOG(TLVL_DEBUG) << message.substr(prev);
42 if (!optional_message.empty())
44 TLOG(TLVL_ERROR) << optional_message;
51 catch (
const art::Exception& e)
53 TLOG(TLVL_ERROR) <<
"art::Exception object caught:"
54 <<
" returnCode = " << e.returnCode() <<
", categoryCode = " << e.categoryCode() <<
", category = " << e.category();
55 TLOG(TLVL_ERROR) <<
"art::Exception object stream:" << e;
60 catch (
const cet::exception& e)
62 TLOG(TLVL_ERROR) <<
"cet::exception object caught:" << e.explain_self();
67 catch (
const boost::exception& e)
69 TLOG(TLVL_ERROR) <<
"boost::exception object caught: " << boost::diagnostic_information(e);
74 catch (
const std::exception& e)
76 TLOG(TLVL_ERROR) <<
"std::exception caught: " << e.what();
83 TLOG(TLVL_ERROR) <<
"Exception of type unknown to artdaq::ExceptionHandler caught";
ExceptionHandlerRethrow
Controls whether the ExceptionHandler will rethrow after printing exception details.
void PrintExceptionStackTrace()
Print the Exception Stack Trace.
Rethrow the exception after sending details to MessageFacility.
void ExceptionHandler(ExceptionHandlerRethrow decision, const std::string &optional_message)
The ExceptionHandler class prints out all available information about an excection, then optionally re-throws.
std::string print_stacktrace()
Produces a stack trace summary.