CLHEP 2.4.6.4
C++ Class Library for High Energy Physics
Loading...
Searching...
No Matches
ZMexHandler.cc
Go to the documentation of this file.
1// ----------------------------------------------------------------------
2//
3// ZMexHandler.cc -- implementations for the standard handlers.
4//
5//
6// The following methods are defined here:
7// standardHandling( ZMexception & x, bool willThrow )
8// ZMexThrowErrors::takeCareOf()
9//
10// Revision History:
11// 970923 PhilC Initial version
12// 971113 WEB Updated to conform to standard coding techniques
13// 980615 WEB Added namespace support
14//
15// ----------------------------------------------------------------------
16
17
18#include "CLHEP/Exceptions/ZMexHandler.h"
19
20#include "CLHEP/Exceptions/ZMexAction.h"
21#include "CLHEP/Exceptions/ZMexception.h"
22#include "CLHEP/Exceptions/ZMexLogResult.h"
23#include "CLHEP/Exceptions/ZMexSeverity.h"
24
25#include <string>
26
27
28namespace zmex {
29
31
32//******************************************
33//
34// standardHandling( ZMexception & x, bool willThrow )
35// provides functionality common to many (most?) handlers:
36// record the handler's name
37// record (via x.wasThrown() ) the determined action
38// obtain permission, from the exception, to log;
39// if granted, invoke the exception's logger
40// return the determined action
41//
42//******************************************
43
46standardHandling( const ZMexception & x, bool willThrow ) {
47
48 x.handlerUsed( name() ); // record handler's name
49 x.wasThrown( willThrow ); // record go/nogo decision
50
51 int & val = ZMexSeverityLimit[ x.severity() ];
52
53 if ( x.OKtoLog() && val != 0 ) // handle logging, if desired
54 if ( x.logMe() == ZMexLOGGED && val > 0 )
55 --val;
56
57 return willThrow ? ZMexThrowIt
59}
60
61
62//*******************************
63//
64// ZMexThrowErrors::takeCareOf()
65//
66//*******************************
67
70takeCareOf( const ZMexception & x ) {
71 //DEBUG cerr << "ThrowErrors::takeCareOf" << endl;
72 return standardHandling( x, ( x.severity() >= ZMexERROR ) ? true
73 : false
74 );
75}
76
77
78} // namespace zmex
ZMexAction standardHandling(const ZMexception &x, bool willThrow)
Definition: ZMexHandler.cc:46
virtual std::string name() const
Definition: ZMexHandler.h:76
virtual ~ZMexHandler()
Definition: ZMexHandler.cc:30
virtual ZMexAction takeCareOf(const ZMexception &x)
Definition: ZMexHandler.cc:70
virtual ZMexLogResult logMe() const
Definition: ZMexception.h:452
std::string handlerUsed() const
bool wasThrown() const
ZMexSeverity severity() const
bool OKtoLog() const
Definition: ZMerrno.h:52
int ZMexSeverityLimit[ZMexSEVERITYenumLAST]
Definition: ZMexSeverity.cc:45
ZMexAction
Definition: ZMexAction.h:20
@ ZMexIgnoreIt
Definition: ZMexAction.h:20
@ ZMexThrowIt
Definition: ZMexAction.h:20
@ ZMexERROR
Definition: ZMexSeverity.h:46
@ ZMexLOGGED
Definition: ZMexLogResult.h:19