32 #include <boost/python.hpp> 33 #include "G4VExceptionHandler.hh" 34 #include "G4StateManager.hh" 45 G4StateManager* sm= G4StateManager::GetStateManager();
46 sm-> SetExceptionHandler(
this);
50 G4bool
Notify(
const char* originOfException,
51 const char* exceptionCode,
52 G4ExceptionSeverity severity,
53 const char* description) {
55 std::ostringstream message;
56 message <<
"*** G4Exception : " << exceptionCode << G4endl
57 <<
" issued by : " << originOfException << G4endl
58 << description << G4endl;
62 PyErr_SetString(PyExc_AssertionError,
63 "*** Fatal Exception ***");
65 G4cerr << message.str() << G4endl;
68 case FatalErrorInArgument:
69 PyErr_SetString(PyExc_ValueError,
70 "*** Fatal Error In Argument ***");
72 G4cerr << message.str() << G4endl;
75 case RunMustBeAborted:
76 PyErr_SetString(PyExc_RuntimeError,
77 "*** Run Must Be Aborted ***");
79 G4cerr << message.str() << G4endl;
82 case EventMustBeAborted:
83 PyErr_SetString(PyExc_RuntimeError,
84 "*** Event Must Be Aborted ***");
86 G4cerr << message.str() << G4endl;
90 PyErr_Warn(PyExc_RuntimeWarning,
91 "*** This is just a warning message. ***");
92 G4cerr << message.str() << G4endl;
106 class_<PyG4ExceptionHandler, boost::noncopyable>
107 (
"G4ExceptionHandler",
"exception handler")
G4bool Notify(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
void export_G4ExceptionHandler()