00001 #include "ExceptionHandler.hh" 00002 00003 #include "canvas/Utilities/Exception.h" 00004 #include "cetlib/exception.h" 00005 #include "tracemf.h" 00006 00007 #include <boost/exception/all.hpp> 00008 00009 #undef TRACE_NAME 00010 #define TRACE_NAME "ExceptionHandler" 00011 00012 namespace artdaq 00013 { 00014 void ExceptionHandler(ExceptionHandlerRethrow decision, std::string optional_message) 00015 { 00016 if (optional_message != "") 00017 { 00018 TLOG(TLVL_ERROR) << optional_message; 00019 } 00020 00021 try 00022 { 00023 throw; 00024 } 00025 catch (const art::Exception& e) 00026 { 00027 TLOG(TLVL_ERROR) << "art::Exception object caught:" << 00028 " returnCode = " << std::to_string(e.returnCode()) << 00029 ", categoryCode = " << e.categoryCode() << 00030 ", category = " << e.category(); 00031 TLOG(TLVL_ERROR) << "art::Exception object stream:" << e; 00032 00033 if (decision == ExceptionHandlerRethrow::yes) { throw; } 00034 } 00035 catch (const cet::exception& e) 00036 { 00037 TLOG(TLVL_ERROR) << "cet::exception object caught:" << 00038 e.explain_self(); 00039 00040 if (decision == ExceptionHandlerRethrow::yes) { throw; } 00041 } 00042 catch (const boost::exception& e) 00043 { 00044 TLOG(TLVL_ERROR) << "boost::exception object caught: " << 00045 boost::diagnostic_information(e); 00046 00047 if (decision == ExceptionHandlerRethrow::yes) { throw; } 00048 } 00049 catch (const std::exception& e) 00050 { 00051 TLOG(TLVL_ERROR) << "std::exception caught: " << e.what(); 00052 00053 if (decision == ExceptionHandlerRethrow::yes) { throw; } 00054 } 00055 catch (...) 00056 { 00057 TLOG(TLVL_ERROR) << "Exception of type unknown to artdaq::ExceptionHandler caught"; 00058 00059 if (decision == ExceptionHandlerRethrow::yes) { throw; } 00060 } 00061 } 00062 }