1 #include "artdaq-core/Utilities/ExceptionHandler.hh"
3 #define BOOST_TEST_MODULE ExceptionHandler_t
4 #include "cetlib/quiet_unit_test.hpp"
6 #define TRACE_NAME "ExceptionHandler_t"
7 #include "canvas/Utilities/Exception.h"
8 #include "cetlib_except/exception.h"
11 #include <boost/exception/all.hpp>
13 BOOST_AUTO_TEST_SUITE(ExceptionHandler_test)
15 typedef boost::error_info<struct tag_my_info, std::
string> my_info;
17 struct
my_error : virtual boost::exception, virtual std::exception
20 BOOST_AUTO_TEST_CASE(artException)
24 throw art::Exception(art::errors::Unknown,
"TestException");
26 catch (art::Exception& e)
29 BOOST_REQUIRE_EXCEPTION(
33 BOOST_AUTO_TEST_CASE(cetException)
37 throw cet::exception(
"TestException");
39 catch (cet::exception&)
42 BOOST_REQUIRE_EXCEPTION(
46 BOOST_AUTO_TEST_CASE(boostException)
50 throw my_error() << my_info(
"TestException");
52 catch (boost::exception&)
55 BOOST_REQUIRE_EXCEPTION(
59 BOOST_AUTO_TEST_CASE(stdException)
63 throw std::exception();
65 catch (std::exception&)
68 BOOST_REQUIRE_EXCEPTION(
72 BOOST_AUTO_TEST_CASE(arbitraryThrow)
81 BOOST_REQUIRE_EXCEPTION(
86 BOOST_AUTO_TEST_SUITE_END()
Consume the exception and proceed.
Rethrow the exception after sending details to MessageFacility.
void ExceptionHandler(ExceptionHandlerRethrow decision, const std::string &optional_message)
The ExceptionHandler class prints out all available information about an excection, then optionally re-throws.