CLHEP 2.4.6.4
C++ Class Library for High Energy Physics
Loading...
Searching...
No Matches
ZMthrow.cc
Go to the documentation of this file.
1// ----------------------------------------------------------------------
2//
3// ZMthrow.cc -- implementation of ZMthrow
4//
5// ZMthrow_() is invoked by the ZMthrow(x) macro, which supplies the lineNum
6// and file arguments as well as the constructed ZOOM exception object.
7//
8// Revision History:
9// 970910 MF Initial version
10// 970916 WEB Updated per code review
11// 970917 WEB Updated per code review 2
12// 980615 WEB Added namespace support
13//
14// ----------------------------------------------------------------------
15
16
17#include "CLHEP/Exceptions/ZMthrow.h"
18#include "CLHEP/Exceptions/ZMerrno.h"
19#include "CLHEP/Exceptions/ZMexAction.h"
20#include "CLHEP/Exceptions/ZMexception.h"
21#include "CLHEP/Exceptions/ZMexSeverity.h"
22
23#include <string>
24
25namespace zmex {
26
27
28
29//**********************
30//
31// ZMthrow_ ()
32//
33//**********************
34
36 const ZMexception & userException
37, int lineNum
38, const char fileName[]
39) {
40
41 // a) Place the lineNum and fileName information into the exception object.
42
43 // b) Cause the handler to be invoked via x.X::handleMe().
44 // That finds the handler, puts the handler name into the exception,
45 // and invokes the handler's takeCareOf() method, passing it the
46 // exception object so that, if any parent handlers are involved,
47 // you later have x.Y::handleMe() invoked, where Y is an ancestor of X.
48
49 // c) If the exception is of severity ZMexERROR or higher, copy the
50 // exception object onto ZMerrno.
51
52 // d) Return the result of the handler's decision.
53
54 // The following are done elsewhere, so ZMthrow_ does not have to:
55 // The constructor for ZMexception takes care of incrementing
56 // the static count, and saving its value.
57 // The handler notifies the exception object of the handler's
58 // decision whether to have the object be thrown or ignored.
59 // Identifying the logger to call, and saving that information,
60 // in this exception instance, is done by x.logMe()
61 // called by handler, assuming the handler decides to log.
62
63 userException.location( lineNum, fileName ); // (a)
64
65 ZMexAction whatToDo = userException.handleMe(); // (b)
66
67 if ( userException.severity() >= ZMexERROR ) // (c)
68 ZMerrno.write( userException );
69
70 return whatToDo; // (d)
71
72} // ZMthrow_()
73
74} // namespace zmex
void write(const ZMexception &x)
Definition: ZMerrno.cc:67
virtual ZMexAction handleMe() const
Definition: ZMexception.h:447
ZMexSeverity severity() const
void location(int line, const std::string file) const
Definition: ZMerrno.h:52
ZMexAction
Definition: ZMexAction.h:20
@ ZMexERROR
Definition: ZMexSeverity.h:46
ZMexAction ZMthrow_(const ZMexception &userException, int lineNum, const char fileName[])
Definition: ZMthrow.cc:35
ZMerrnoList ZMerrno
Definition: ZMerrno.cc:40