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 #ifdef HAVE_CANVAS
00037 #include "canvas/Utilities/Exception.h"
00038 #else
00039 #include "art/Utilities/Exception.h"
00040 #endif
00041 #include "cetlib/exception.h"
00042 #include "messagefacility/MessageLogger/MessageLogger.h"
00043
00044 #include <boost/exception/all.hpp>
00045
00046 #include <stdexcept>
00047
00048 namespace artdaq {
00049
00050 void ExceptionHandler(ExceptionHandlerRethrow decision, std::string optional_message) {
00051
00052 if (optional_message != "") {
00053 mf::LogError("ExceptionHandler") << optional_message;
00054 }
00055
00056 try {
00057 throw;
00058 } catch (const art::Exception& e) {
00059
00060 mf::LogError("ExceptionHandler") << "art::Exception object caught:" <<
00061 " returnCode = " << e.returnCode() <<
00062 ", categoryCode = " << e.categoryCode() <<
00063 ", category = " << e.category();
00064 mf::LogError("ExceptionHandler") << "art::Exception object stream:" << e;
00065
00066 if (decision == ExceptionHandlerRethrow::yes) { throw; }
00067
00068 } catch (const cet::exception &e) {
00069
00070 mf::LogError("ExceptionHandler") << "cet::exception object caught:" <<
00071 e.explain_self();
00072
00073 if (decision == ExceptionHandlerRethrow::yes) { throw; }
00074
00075 } catch (const boost::exception& e) {
00076
00077 mf::LogError("ExceptionHandler") << "boost::exception object caught: " <<
00078 boost::diagnostic_information(e);
00079
00080 if (decision == ExceptionHandlerRethrow::yes) { throw; }
00081
00082 } catch (const std::exception& e ) {
00083
00084 mf::LogError ("ExceptionHandler") << "std::exception caught: " << e.what();
00085
00086 if (decision == ExceptionHandlerRethrow::yes) { throw; }
00087
00088 } catch (...) {
00089
00090 mf::LogError ("ExceptionHandler") << "Exception of type unknown to artdaq::ExceptionHandler caught";
00091
00092 if (decision == ExceptionHandlerRethrow::yes) { throw; }
00093
00094 }
00095 }
00096
00097 }