CLHEP 2.0.4.7 Reference Documentation
   
CLHEP Home Page     CLHEP Documentation     CLHEP Bug Reports

ZMthrow.cc

Go to the documentation of this file.
00001 // ----------------------------------------------------------------------
00002 //
00003 // ZMthrow.cc -- implementation of ZMthrow
00004 //
00005 // ZMthrow_() is invoked by the ZMthrow(x) macro, which supplies the lineNum
00006 // and file arguments as well as the constructed ZOOM exception object.
00007 //
00008 // Revision History:
00009 //      970910  MF      Initial version
00010 //      970916  WEB     Updated per code review
00011 //      970917  WEB     Updated per code review 2
00012 //      980615  WEB     Added namespace support
00013 //
00014 // ----------------------------------------------------------------------
00015 
00016 
00017 #include "CLHEP/Exceptions/ZMthrow.h"
00018 #include "CLHEP/Exceptions/ZMexSeverity.h"
00019 #include "CLHEP/Exceptions/ZMexception.h"
00020 #include "CLHEP/Exceptions/ZMerrno.h"
00021 
00022 
00023 namespace zmex  {
00024 
00025 
00026 
00027 //**********************
00028 //
00029 // ZMthrow_ ()
00030 //
00031 //**********************
00032 
00033 ZMexAction ZMthrow_(
00034   const ZMexception & userException
00035 , int                 lineNum
00036 , const char          fileName[]
00037 )  {
00038 
00039   // a) Place the lineNum and fileName information into the exception object.
00040 
00041   // b) Cause the handler to be invoked via x.X::handleMe().
00042   //    That finds the handler, puts the handler name into the exception,
00043   //    and invokes the handler's takeCareOf() method, passing it the
00044   //    exception object so that, if any parent handlers are involved,
00045   //    you later have x.Y::handleMe() invoked, where Y is an ancestor of X.
00046 
00047   // c) If the exception is of severity ZMexERROR or higher, copy the
00048   //    exception object onto ZMerrno.
00049 
00050   // d) Return the result of the handler's decision.
00051 
00052   // The following are done elsewhere, so ZMthrow_ does not have to:
00053   //   The constructor for ZMexception takes care of incrementing
00054   //     the static count, and saving its value.
00055   //   The handler notifies the exception object of the handler's
00056   //     decision whether to have the object be thrown or ignored.
00057   //   Identifying the logger to call, and saving that information,
00058   //     in this exception instance, is done by x.logMe()
00059   //     called by handler, assuming the handler decides to log.
00060 
00061   userException.location( lineNum, fileName );          // (a)
00062 
00063   ZMexAction whatToDo = userException.handleMe();       // (b)
00064 
00065   if ( userException.severity() >= ZMexERROR )          // (c)
00066     ZMerrno.write( userException );
00067 
00068   return whatToDo;                                      // (d)
00069 
00070 }  // ZMthrow_()
00071 
00072 }  // namespace zmex

Generated on Thu Jul 1 22:02:31 2010 for CLHEP by  doxygen 1.4.7