Commit 10824728 authored by Simon Spannagel's avatar Simon Spannagel
Browse files

G4ExceptionHandler: catch JustWarning-type Exceptions

parent ad481187
Loading
Loading
Loading
Loading
+11 −2
Original line number Diff line number Diff line
@@ -13,6 +13,7 @@
#define ALLPIX_GEANT4_EXCEPTIONS_H

#include "core/module/exceptions.h"
#include "core/utils/log.h"

#include <G4VExceptionHandler.hh>

@@ -27,8 +28,16 @@ namespace allpix {
     */
    class G4ExceptionHandler : public G4VExceptionHandler {
    public:
        G4bool Notify(const char*, const char* exceptionCode, G4ExceptionSeverity, const char* description) override {
            throw ModuleError("Caught Geant4 exception " + std::string(exceptionCode) + ": " + std::string(description));
        G4bool Notify(const char*, const char* code, G4ExceptionSeverity severity, const char* description) override {
            std::string message = "Caught Geant4 exception " + std::string(code) + ": " + std::string(description);
            if(severity == G4ExceptionSeverity::JustWarning) {
                LOG(WARNING) << message;
            } else {
                throw ModuleError(message);
            }

            // Continue program execution:
            return false;
        };
    };