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 #include <stdexcept>
00043
00044 namespace artdaq {
00045
00046 void ExceptionHandler(ExceptionHandlerRethrow decision, std::string optional_message) {
00047
00048 if (optional_message != "") {
00049 mf::LogError("ExceptionHandler") << optional_message;
00050 }
00051
00052 try {
00053 throw;
00054 } catch (const art::Exception& e) {
00055
00056 mf::LogError("ExceptionHandler") << "art::Exception object caught:" <<
00057 " returnCode = " << e.returnCode() <<
00058 ", categoryCode = " << e.categoryCode() <<
00059 ", category = " << e.category();
00060 mf::LogError("ExceptionHandler") << "art::Exception object stream:" << e;
00061
00062 if (decision == ExceptionHandlerRethrow::yes) { throw; }
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 } catch (const boost::exception& e) {
00072
00073 mf::LogError("ExceptionHandler") << "boost::exception object caught: " <<
00074 boost::diagnostic_information(e);
00075
00076 if (decision == ExceptionHandlerRethrow::yes) { throw; }
00077
00078 } catch (const std::exception& e ) {
00079
00080 mf::LogError ("ExceptionHandler") << "std::exception caught: " << e.what();
00081
00082 if (decision == ExceptionHandlerRethrow::yes) { throw; }
00083
00084 } catch (...) {
00085
00086 mf::LogError ("ExceptionHandler") << "Exception of type unknown to artdaq::ExceptionHandler caught";
00087
00088 if (decision == ExceptionHandlerRethrow::yes) { throw; }
00089
00090 }
00091 }
00092
00093 }