00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034 #include "ExceptionHandler.hh"
00035
00036 #include "canvas/Utilities/Exception.h"
00037 #include "cetlib/exception.h"
00038 #include "messagefacility/MessageLogger/MessageLogger.h"
00039
00040 #include <boost/exception/all.hpp>
00041
00042 namespace artdaq {
00043
00044 void ExceptionHandler(ExceptionHandlerRethrow decision, std::string optional_message) {
00045
00046 if (optional_message != "") {
00047 mf::LogError("ExceptionHandler") << optional_message;
00048 }
00049
00050 try {
00051 throw;
00052 }
00053 catch (const art::Exception& e) {
00054
00055 mf::LogError("ExceptionHandler") << "art::Exception object caught:" <<
00056 " returnCode = " << std::to_string(e.returnCode()) <<
00057 ", categoryCode = " << e.categoryCode() <<
00058 ", category = " << e.category();
00059 mf::LogError("ExceptionHandler") << "art::Exception object stream:" << e;
00060
00061 if (decision == ExceptionHandlerRethrow::yes) { throw; }
00062
00063 }
00064 catch (const cet::exception &e) {
00065
00066 mf::LogError("ExceptionHandler") << "cet::exception object caught:" <<
00067 e.explain_self();
00068
00069 if (decision == ExceptionHandlerRethrow::yes) { throw; }
00070
00071 }
00072 catch (const boost::exception& e) {
00073
00074 mf::LogError("ExceptionHandler") << "boost::exception object caught: " <<
00075 boost::diagnostic_information(e);
00076
00077 if (decision == ExceptionHandlerRethrow::yes) { throw; }
00078
00079 }
00080 catch (const std::exception& e) {
00081
00082 mf::LogError("ExceptionHandler") << "std::exception caught: " << e.what();
00083
00084 if (decision == ExceptionHandlerRethrow::yes) { throw; }
00085
00086 }
00087 catch (...) {
00088
00089 mf::LogError("ExceptionHandler") << "Exception of type unknown to artdaq::ExceptionHandler caught";
00090
00091 if (decision == ExceptionHandlerRethrow::yes) { throw; }
00092
00093 }
00094 }
00095
00096 }