ExceptionCollector.h
Go to the documentation of this file.
1 #ifndef art_Framework_EventProcessor_detail_ExceptionCollector_h
2 #define art_Framework_EventProcessor_detail_ExceptionCollector_h
3 
4 // ======================================================================
5 //
6 // ExceptionCollector - Utility used to collect exceptions thrown when
7 // invoking functions that were provided to ExceptionCollector::call.
8 // The semantics are different than cet::exception_collector in that
9 // the (compiled-generated) ExceptionCollector d'tor DOES NOT call
10 // rethrow.
11 //
12 // TODO: determine if this class should be removed in favor of the
13 // cet::exception_collector class.
14 //
15 // ======================================================================
16 
17 #include <exception>
18 #include <string>
19 #include <vector>
20 
21 namespace art::detail {
23  public:
24  bool
25  empty() const noexcept
26  {
27  return exceptions_.empty();
28  }
29  [[noreturn]] void rethrow();
30 
31  template <typename F>
32  void
33  call(F f) try {
34  f();
35  }
36  catch (...) {
37  exceptions_.push_back(std::current_exception());
38  }
39 
40  private:
41  std::vector<std::exception_ptr> exceptions_{};
42  };
43 
45  public:
46  explicit collected_exception(std::string msg) : msg_(move(msg)) {}
47  char const*
48  what() const noexcept override
49  {
50  return msg_.c_str();
51  }
52 
53  private:
55  };
56 }
57 
58 #endif /* art_Framework_EventProcessor_detail_ExceptionCollector_h */
59 
60 // Local Variables:
61 // mode: c++
62 // End:
void msg(const char *fmt,...)
Definition: message.cpp:107
std::string string
Definition: nybbler.cc:12
char const * what() const noexcept override
std::vector< std::exception_ptr > exceptions_
def move(depos, offset)
Definition: depos.py:107
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33