ExceptionDerived_t.cc
Go to the documentation of this file.
1 #include "cetlib_except/exception.h"
2 
3 #include <iostream>
4 #include <string>
5 
6 struct Thing : public cet::exception {
7  Thing(const std::string& msg) : exception("Thing", msg) {}
8 };
9 
10 std::ostream&
11 operator<<(std::ostream& os, const Thing& t)
12 {
13  os << "Thing(" << t.explain_self() << ")";
14  return os;
15 }
16 
17 [[noreturn]] void
19 {
20  throw Thing("Data Corrupt") << " Low level error" << std::endl;
21 }
22 
23 [[noreturn]] void
25 {
26  func3();
27 }
28 
29 [[noreturn]] void
30 func1() try {
31  func2();
32 }
33 catch (cet::exception& e) {
34  throw cet::exception("InfiniteLoop", "In func2", e) << "Gave up";
35 }
36 
37 int
38 main() try {
39  func1();
40 }
41 catch (cet::exception& e) {
42  std::cerr << "*** main caught cet::exception, output is ***\n"
43  << "(" << e.explain_self() << ")"
44  << "*** After exception output ***" << std::endl;
45 
46  std::cerr << "\nCategory name list:\n";
47 }
void msg(const char *fmt,...)
Definition: message.cpp:107
std::string string
Definition: nybbler.cc:12
std::ostream & operator<<(std::ostream &os, const Thing &t)
const double e
void func3()
int main()
void func2()
Thing(const std::string &msg)
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
QTextStream & endl(QTextStream &s)
void func1()