src/core/module/exceptions.h

Collection of all module exceptions. More…

Namespaces

Name
allpix
Helper class to hold support layers for a detector model.

Classes

Name
class allpix::DynamicLibraryError
Notifies of an error with dynamically loading a module.
class allpix::AmbiguousInstantiationError
Raised if ambiguous instantiation of two similar modules occurs.
class allpix::InvalidModuleStateException
Informs that a module is in a state it should never be.
class allpix::InvalidEventStateException
Informs that an event is in a state it should never be.
class allpix::InvalidModuleActionException
Informs that a module executes an action is it not allowed to do in particular state.
class allpix::ModuleError
General exception for modules if something goes wrong.
class allpix::EndOfRunException
Exception for modules to request an end of the event processing.
class allpix::AbortEventException
Exception for modules to request the abortion of the current event.
class allpix::MissingDependenciesException
Exception for modules to request an interrupt because dependencies are missing.

Detailed Description

Collection of all module exceptions.

Copyright: Copyright (c) 2017-2024 CERN and the Allpix Squared authors. This software is distributed under the terms of the MIT License, copied verbatim in the file “LICENSE.md”. In applying this license, CERN does not waive the privileges and immunities granted to it by virtue of its status as an Intergovernmental Organization or submit itself to any jurisdiction. SPDX-License-Identifier: MIT

Source code


#ifndef ALLPIX_MODULE_EXCEPTIONS_H
#define ALLPIX_MODULE_EXCEPTIONS_H

#include <string>

#include "core/utils/exceptions.h"
#include "core/utils/type.h"

namespace allpix {
    class DynamicLibraryError : public RuntimeError {
    public:
        explicit DynamicLibraryError(const std::string& module) {
            error_message_ = "Dynamic library loading failed for module " + module;
        }
    };

    class AmbiguousInstantiationError : public RuntimeError {
    public:
        explicit AmbiguousInstantiationError(const std::string& module) {
            // FIXME: add detector and input output instance here
            error_message_ = "Two modules of type " + module +
                             " instantiated with same unique identifier and priority, cannot choose correct one";
        }
    };

    class InvalidModuleStateException : public LogicError {
    public:
        // TODO [doc] the module itself is missing
        explicit InvalidModuleStateException(std::string message) { error_message_ = std::move(message); }
    };

    class InvalidEventStateException : public LogicError {
    public:
        // TODO [doc] the event itself is missing
        explicit InvalidEventStateException(std::string message) { error_message_ = std::move(message); }
    };

    class InvalidModuleActionException : public LogicError {
    public:
        // TODO [doc] the module itself is missing
        explicit InvalidModuleActionException(std::string message) { error_message_ = std::move(message); }
    };

    class ModuleError : public RuntimeError {
    public:
        // TODO [doc] the module itself is missing
        explicit ModuleError(std::string reason) { error_message_ = std::move(reason); }
    };

    class EndOfRunException : public RuntimeError {
    public:
        // TODO [doc] the module itself is missing
        explicit EndOfRunException(std::string reason) { error_message_ = std::move(reason); }
    };

    class AbortEventException : public EndOfRunException {
    public:
        // TODO [doc] the module itself is missing
        explicit AbortEventException(std::string reason) : EndOfRunException(reason) { error_message_ = std::move(reason); }
    };

    class MissingDependenciesException : public RuntimeError {
    public:
        MissingDependenciesException() = default;
    };
} // namespace allpix

#endif /* ALLPIX_MODULE_EXCEPTIONS_H */

Updated on 2024-12-13 at 08:31:37 +0000