Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Functions
pyG4Exception Namespace Reference

Functions

void f2_G4Exception (const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
 

Function Documentation

void pyG4Exception::f2_G4Exception ( const char *  originOfException,
const char *  exceptionCode,
G4ExceptionSeverity  severity,
const char *  description 
)

Definition at line 44 of file pyG4Exception.cc.

References EventMustBeAborted, FatalErrorInArgument, FatalException, G4cerr, G4cout, G4endl, G4State_Abort, G4StateManager::GetStateManager(), and RunMustBeAborted.

Referenced by export_G4Exception().

49 {
50  G4VExceptionHandler* exceptionHandler
51  = G4StateManager::GetStateManager()-> GetExceptionHandler();
52  G4bool toBeAborted = true;
53  if(exceptionHandler) {
54  toBeAborted = exceptionHandler
55  -> Notify(originOfException,exceptionCode,severity,description);
56  } else {
57  G4String e_banner = "\n!!!!! - !!!!! - !!!!! - !!!!! - !!!!! - !!!!!\n";
58  G4String w_banner = "\nwwwww - wwwww - wwwww - wwwww - wwwww - wwwww\n";
59  std::ostringstream message;
60  message << "\n*** ExceptionHandler is not defined ***\n"
61  << "*** G4Exception : " << exceptionCode << G4endl
62  << " issued by : " << originOfException << G4endl
63  << description << G4endl;
64  switch(severity) {
65  case FatalException:
66  G4cerr << e_banner << message.str() << "*** Fatal Exception ***"
67  << e_banner;
68  break;
70  G4cerr << e_banner << message.str() << "*** Fatal Error In Argument ***"
71  << e_banner;
72  break;
73  case RunMustBeAborted:
74  G4cerr << e_banner << message.str() << "*** Run Must Be Aborted ***"
75  << e_banner;
76  break;
77  case EventMustBeAborted:
78  G4cerr << e_banner << message.str() << "*** Event Must Be Aborted ***"
79  << e_banner;
80  break;
81  default:
82  G4cout << w_banner << message.str()
83  << "*** This is just a warning message. ***"
84  << w_banner;
85  toBeAborted = false;
86  break;
87  }
88  }
89 
90  if(toBeAborted) {
92  G4cerr << G4endl << "*** G4Exception: Aborting execution ***" << G4endl;
93  PyErr_SetString(PyExc_RuntimeError, description);
94  PyErr_Print();
95  } else {
96  G4cerr << G4endl << "*** G4Exception: Abortion suppressed ***"
97  << G4endl << "*** No guarantee for further execution ***"
98  << G4endl;
99  }
100  }
101 }
static G4StateManager * GetStateManager()
G4GLOB_DLL std::ostream G4cout
bool G4bool
Definition: G4Types.hh:79
#define G4endl
Definition: G4ios.hh:61
G4GLOB_DLL std::ostream G4cerr