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