34 #include "ExceptionHandler.hh"
36 #include "canvas/Utilities/Exception.h"
37 #include "cetlib/exception.h"
38 #include "messagefacility/MessageLogger/MessageLogger.h"
40 #include <boost/exception/all.hpp>
44 void ExceptionHandler(ExceptionHandlerRethrow decision, std::string optional_message) {
46 if (optional_message !=
"") {
47 mf::LogError(
"ExceptionHandler") << optional_message;
53 catch (
const art::Exception& e) {
55 mf::LogError(
"ExceptionHandler") <<
"art::Exception object caught:" <<
56 " returnCode = " << std::to_string(e.returnCode()) <<
57 ", categoryCode = " << e.categoryCode() <<
58 ", category = " << e.category();
59 mf::LogError(
"ExceptionHandler") <<
"art::Exception object stream:" << e;
61 if (decision == ExceptionHandlerRethrow::yes) {
throw; }
64 catch (
const cet::exception &e) {
66 mf::LogError(
"ExceptionHandler") <<
"cet::exception object caught:" <<
69 if (decision == ExceptionHandlerRethrow::yes) {
throw; }
72 catch (
const boost::exception& e) {
74 mf::LogError(
"ExceptionHandler") <<
"boost::exception object caught: " <<
75 boost::diagnostic_information(e);
77 if (decision == ExceptionHandlerRethrow::yes) {
throw; }
80 catch (
const std::exception& e) {
82 mf::LogError(
"ExceptionHandler") <<
"std::exception caught: " << e.what();
84 if (decision == ExceptionHandlerRethrow::yes) {
throw; }
89 mf::LogError(
"ExceptionHandler") <<
"Exception of type unknown to artdaq::ExceptionHandler caught";
91 if (decision == ExceptionHandlerRethrow::yes) {
throw; }