src/core/messenger/exceptions.h

Collection of all message exceptions. More…

Namespaces

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

Classes

Name
class allpix::UnexpectedMessageException
Receive of a message that was not expected.
class allpix::MessageWithoutObjectException
Message does not contain an allpix::Object.
class allpix::MessageNotFoundException
Trying to fetch a message that wasn’t delivered.

Detailed Description

Collection of all message 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_MESSENGER_EXCEPTIONS_H
#define ALLPIX_MESSENGER_EXCEPTIONS_H

#include <string>

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

namespace allpix {
    // TODO [doc] Should be renamed to UnexpectedMessageError
    class UnexpectedMessageException : public RuntimeError {
    public:
        UnexpectedMessageException(const std::string& module, const std::type_info& message) {
            // FIXME: add detector and input output instance here
            error_message_ = "Unexpected message ";
            error_message_ += allpix::demangle(message.name());
            error_message_ += " received by module " + module + " (only a single one expected per event)";
        }
    };

    class MessageWithoutObjectException : public RuntimeError {
    public:
        explicit MessageWithoutObjectException(const std::type_info& message) {
            error_message_ = "Message ";
            error_message_ += allpix::demangle(message.name());
            error_message_ += " does not contain a valid object";
        }
    };

    class MessageNotFoundException : public RuntimeError {
    public:
        explicit MessageNotFoundException(const std::string& module, const std::type_info& message) {
            error_message_ = "Module " + module + " did not receive message ";
            error_message_ += allpix::demangle(message.name());
        }
    };
} // namespace allpix

#endif /* ALLPIX_MESSENGER_EXCEPTIONS_H */

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