Celeritas  0.5.0-56+6b053cd
Public Member Functions | List of all members
celeritas::ExceptionConverter Class Reference

Translate Celeritas C++ exceptions into Geant4 G4Exception calls. More...

#include <ExceptionConverter.hh>

Public Member Functions

 ExceptionConverter (char const *err_code, SharedParams const *params)
 Construct with an error code and shared parameters. More...
 
 ExceptionConverter (char const *err_code)
 Construct with an error code for dispatching to Geant4.
 
void operator() (std::exception_ptr p) const
 Capture the current exception and convert it to a G4Exception call.
 

Detailed Description

Translate Celeritas C++ exceptions into Geant4 G4Exception calls.

This should generally be used when wrapping calls to Celeritas in a user application.

For example, the user event action to transport particles on device could be used as:

void EventAction::EndOfEventAction(const G4Event*)
{
// Transport any tracks left in the buffer
celeritas::ExceptionConverter call_g4exception{"celer0003"};
CELER_TRY_HANDLE(transport_->Flush(), call_g4exception);
}
#define CELER_TRY_HANDLE(STATEMENT, HANDLE_EXCEPTION)
"Try" to execute the statement, and "handle" all thrown errors by calling the given function-like err...
Definition: Macros.hh:186
Translate Celeritas C++ exceptions into Geant4 G4Exception calls.
Definition: ExceptionConverter.hh:34

Constructor & Destructor Documentation

◆ ExceptionConverter()

celeritas::ExceptionConverter::ExceptionConverter ( char const *  err_code,
SharedParams const *  params 
)
inline

Construct with an error code and shared parameters.

The error code is reported to the Geant4 exception manager. The shared parameters are used to translate internal particle data if an exception occurs.


The documentation for this class was generated from the following files: