testAugerException.cc
Go to the documentation of this file.
1 /*
2  Test auger excpetion hierarchy
3 */
4 
5 #include <iostream>
6 #include <utl/AugerException.h>
7 
8 using namespace std;
9 using namespace utl;
10 
11 void
13 {
14  throw AugerException("Throwing in throwGeneric.");
15  return;
16 }
17 
18 
19 void
21 {
22  throw NonExistentComponentException("Throwing in throwNonExistent.");
23  return;
24 }
25 
26 
27 int
29 {
30  cerr << "==> Throw and catch generic exception" << endl;
31  try {
32  throwGeneric();
33  } catch (AugerException& ex) {
34  cerr << "Auger exception: " << ex.GetExceptionName()
35  << "\nMessage: " << ex.GetMessage() << endl;
36  }
37 
38  cerr << "==> Throw derived exception, catch with ancestor" << endl;
39  try {
41  } catch (AugerException& ex) {
42  cerr << "Auger exception: " << ex.GetExceptionName()
43  << "\nMessage: " << ex.GetMessage() << endl;
44  }
45 
46  cerr << "==> Throw generic exception, provide handler for generic and derived"
47  << endl;
48  try {
49  throwGeneric();
50  } catch (NonExistentComponentException& ex) {
51  cerr << "Non-existent component exception: "
52  << ex.GetExceptionName()
53  << "\nMessage: " << ex.GetMessage() << endl;
54  } catch (AugerException& ex) {
55  cerr << "Auger exception: " << ex.GetExceptionName()
56  << "\nMessage: " << ex.GetMessage() << endl;
57  }
58 
59  cerr << "==> Throw derived exception, provide handler for generic and derived"
60  << endl;
61  try {
63  } catch (NonExistentComponentException& ex) {
64  cerr << "Non-existent component exception: "
65  << ex.GetExceptionName()
66  << "\nMessage: " << ex.GetMessage() << endl;
67  } catch (AugerException& ex) {
68  cerr << "Auger exception: " << ex.GetExceptionName()
69  << "\nMessage: " << ex.GetMessage() << endl;
70  }
71 
72  return 0;
73 }
74 
75 
76 // Configure (x)emacs for this file ...
77 // Local Variables:
78 // mode: c++
79 // compile-command: "cd ..; make -k check"
80 // End:
Base class for all exceptions used in the auger offline code.
Base class for exceptions trying to access non-existing components.
int main(int argc, char *argv[])
Definition: DBSync.cc:58
void throwGeneric()
const std::string & GetMessage() const
Retrieve the message from the exception.
void throwNonExistent()

, generated on Tue Sep 26 2023.