00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 #include "G4ios.hh"
00038 #include "G4String.hh"
00039 #include "G4StateManager.hh"
00040
00041 void G4Exception(const char* originOfException,
00042 const char* exceptionCode,
00043 G4ExceptionSeverity severity,
00044 const char* description)
00045 {
00046 G4VExceptionHandler* exceptionHandler
00047 = G4StateManager::GetStateManager()->GetExceptionHandler();
00048 G4bool toBeAborted = true;
00049 if(exceptionHandler)
00050 {
00051 toBeAborted = exceptionHandler
00052 ->Notify(originOfException,exceptionCode,severity,description);
00053 }
00054 else
00055 {
00056 static const G4String es_banner
00057 = "\n-------- EEEE ------- G4Exception-START -------- EEEE -------\n";
00058 static const G4String ee_banner
00059 = "\n-------- EEEE -------- G4Exception-END --------- EEEE -------\n";
00060 static const G4String ws_banner
00061 = "\n-------- WWWW ------- G4Exception-START -------- WWWW -------\n";
00062 static const G4String we_banner
00063 = "\n-------- WWWW -------- G4Exception-END --------- WWWW -------\n";
00064 std::ostringstream message;
00065 message << "\n*** ExceptionHandler is not defined ***\n"
00066 << "*** G4Exception : " << exceptionCode << G4endl
00067 << " issued by : " << originOfException << G4endl
00068 << description << G4endl;
00069 switch(severity)
00070 {
00071 case FatalException:
00072 G4cerr << es_banner << message.str() << "*** Fatal Exception ***"
00073 << ee_banner << G4endl;
00074 break;
00075 case FatalErrorInArgument:
00076 G4cerr << es_banner << message.str() << "*** Fatal Error In Argument ***"
00077 << ee_banner << G4endl;
00078 break;
00079 case RunMustBeAborted:
00080 G4cerr << es_banner << message.str() << "*** Run Must Be Aborted ***"
00081 << ee_banner << G4endl;
00082 break;
00083 case EventMustBeAborted:
00084 G4cerr << es_banner << message.str() << "*** Event Must Be Aborted ***"
00085 << ee_banner << G4endl;
00086 break;
00087 default:
00088 G4cout << ws_banner << message.str()
00089 << "*** This is just a warning message. ***"
00090 << we_banner << G4endl;
00091 toBeAborted = false;
00092 break;
00093 }
00094 }
00095 if(toBeAborted)
00096 {
00097 if(G4StateManager::GetStateManager()->SetNewState(G4State_Abort))
00098 {
00099 G4cerr << G4endl << "*** G4Exception: Aborting execution ***" << G4endl;
00100 abort();
00101 }
00102 else
00103 {
00104 G4cerr << G4endl << "*** G4Exception: Abortion suppressed ***"
00105 << G4endl << "*** No guarantee for further execution ***" << G4endl;
00106 }
00107 }
00108 }
00109
00110 void G4Exception(const char* originOfException,
00111 const char* exceptionCode,
00112 G4ExceptionSeverity severity,
00113 G4ExceptionDescription & description)
00114 {
00115 G4String des = description.str();
00116 G4Exception(originOfException, exceptionCode, severity, des.c_str());
00117 }
00118
00119 void G4Exception(const char* originOfException,
00120 const char* exceptionCode,
00121 G4ExceptionSeverity severity,
00122 G4ExceptionDescription & description,
00123 const char* comments)
00124 {
00125 description << comments << G4endl;
00126 G4Exception(originOfException, exceptionCode, severity, description);
00127 }