CLHEP VERSION Reference Documentation
CLHEP Home Page CLHEP Documentation CLHEP Bug Reports |
00001 // ---------------------------------------------------------------------- 00002 // 00003 // ZMexHandler.cc -- implementations for the standard handlers. 00004 // 00005 // 00006 // The following methods are defined here: 00007 // standardHandling( ZMexception & x, bool willThrow ) 00008 // ZMexThrowErrors::takeCareOf() 00009 // 00010 // Revision History: 00011 // 970923 PhilC Initial version 00012 // 971113 WEB Updated to conform to standard coding techniques 00013 // 980615 WEB Added namespace support 00014 // 00015 // ---------------------------------------------------------------------- 00016 00017 00018 #include "CLHEP/Exceptions/ZMexHandler.h" 00019 00020 #include "CLHEP/Exceptions/ZMexception.h" 00021 00022 00023 namespace zmex { 00024 00025 00026 //****************************************** 00027 // 00028 // standardHandling( ZMexception & x, bool willThrow ) 00029 // provides functionality common to many (most?) handlers: 00030 // record the handler's name 00031 // record (via x.wasThrown() ) the determined action 00032 // obtain permission, from the exception, to log; 00033 // if granted, invoke the exception's logger 00034 // return the determined action 00035 // 00036 //****************************************** 00037 00038 ZMexAction 00039 ZMexHandlerBehavior:: 00040 standardHandling( const ZMexception & x, bool willThrow ) { 00041 00042 x.handlerUsed( name() ); // record handler's name 00043 x.wasThrown( willThrow ); // record go/nogo decision 00044 00045 int & val = ZMexSeverityLimit[ x.severity() ]; 00046 00047 if ( x.OKtoLog() && val != 0 ) // handle logging, if desired 00048 if ( x.logMe() == ZMexLOGGED && val > 0 ) 00049 --val; 00050 00051 return willThrow ? ZMexThrowIt 00052 : ZMexIgnoreIt; 00053 } 00054 00055 00056 //******************************* 00057 // 00058 // ZMexThrowErrors::takeCareOf() 00059 // 00060 //******************************* 00061 00062 ZMexAction 00063 ZMexThrowErrors:: 00064 takeCareOf( const ZMexception & x ) { 00065 //DEBUG cerr << "ThrowErrors::takeCareOf" << endl; 00066 return standardHandling( x, ( x.severity() >= ZMexERROR ) ? true 00067 : false 00068 ); 00069 } 00070 00071 00072 } // namespace zmex