Celeritas 0.7.0-dev.79+develop.b3dc2e108
|
Convert Geant4 exceptions to RuntimeError during this class lifetime. More...
#include <ScopedGeantExceptionHandler.hh>
Public Types | |
Type aliases | |
using | StdExceptionHandler = std::function< void(std::exception_ptr)> |
Public Member Functions | |
ScopedGeantExceptionHandler () | |
Construct, throwing on G4Exception calls. | |
CELER_DELETE_COPY_MOVE (ScopedGeantExceptionHandler) | |
Prevent copying and moving for RAII class. | |
ScopedGeantExceptionHandler (StdExceptionHandler handle) | |
Install the Celeritas Geant4 exception handler. | |
Convert Geant4 exceptions to RuntimeError during this class lifetime.
Note that creating a G4RunManagerKernel
resets the exception handler, so errors thrown during setup cannot be caught by Celeritas, and this class can only be used after creating the G4RunManager
.
Because the underlying Geant4 error handler is thread-local, this class must be scoped to inside each worker thread. Additionally, since throwing from a worker thread terminates the program, an error handler must be specified if used in a worker thread: you should probably use a celeritas::MultiExceptionHandler
.
|
inlineexplicit |
Install the Celeritas Geant4 exception handler.
The base class of the exception handler calls SetExceptionHandler...
Do nothing if Geant4 is disabled (source file will not be compiled)