| helics 3.6.1

core-exceptions.hpp
Go to the documentation of this file.
1 /*
2 Copyright (c) 2017-2025,
3 Battelle Memorial Institute; Lawrence Livermore National Security, LLC; Alliance for Sustainable
4 Energy, LLC. See the top-level NOTICE for additional details. All rights reserved.
5 SPDX-License-Identifier: BSD-3-Clause
6 */
7 #pragma once
8 #include <stdexcept>
9 #include <string>
10 #include <string_view>
11
16 namespace helics {
18 class HelicsException: public std::exception {
19 private:
20 std::string errorMessage = "HELICS EXCEPTION";
21
22 public:
23 HelicsException() = default;
24 explicit HelicsException(std::string_view message) noexcept: errorMessage(message) {}
25 virtual const char* what() const noexcept override { return errorMessage.c_str(); }
26 };
27
29 class FunctionExecutionFailure: public HelicsException {
30 public:
31 explicit FunctionExecutionFailure(
32 std::string_view message = "HELICS execution failure") noexcept: HelicsException(message)
33 {
34 }
35 };
36
38 class InvalidIdentifier: public HelicsException {
39 public:
40 explicit InvalidIdentifier(std::string_view message = "invalid identifier") noexcept:
41 HelicsException(message)
42 {
43 }
44 };
45
47 class InvalidParameter: public HelicsException {
48 public:
49 explicit InvalidParameter(std::string_view message = "invalid parameter") noexcept:
50 HelicsException(message)
51 {
52 }
53 };
54
56 class InvalidConversion: public HelicsException {
57 public:
58 explicit InvalidConversion(
59 std::string_view message = "unable to perform the requested conversion") noexcept:
60 HelicsException(message)
61 {
62 }
63 };
64
66 class InvalidFunctionCall: public HelicsException {
67 public:
68 explicit InvalidFunctionCall(std::string_view message = "invalid function call") noexcept:
69 HelicsException(message)
70 {
71 }
72 };
73
75 class ConnectionFailure: public HelicsException {
76 public:
77 explicit ConnectionFailure(std::string_view message = "failed to connect") noexcept:
78 HelicsException(message)
79 {
80 }
81 };
82
84 class RegistrationFailure: public HelicsException {
85 public:
86 explicit RegistrationFailure(std::string_view message = "registration failure") noexcept:
87 HelicsException(message)
88 {
89 }
90 };
91
93 class HelicsSystemFailure: public HelicsException {
94 public:
95 explicit HelicsSystemFailure(std::string_view message = "HELICS system failure") noexcept:
96 HelicsException(message)
97 {
98 }
99 };
100
102 class FederateError: public HelicsException {
103 public:
104 int code{0};
105 FederateError(int errorCode, std::string_view message) noexcept:
106 HelicsException(message), code(errorCode)
107 {
108 }
109 };
110 } // namespace helics
helics::ConnectionFailure
Definition: core-exceptions.hpp:75
helics::FederateError
Definition: core-exceptions.hpp:102
helics::FunctionExecutionFailure
Definition: core-exceptions.hpp:29
helics::HelicsException
Definition: core-exceptions.hpp:18
helics::HelicsSystemFailure
Definition: core-exceptions.hpp:93
helics::InvalidConversion
Definition: core-exceptions.hpp:56
helics::InvalidFunctionCall
Definition: core-exceptions.hpp:66
helics::InvalidIdentifier
Definition: core-exceptions.hpp:38
helics::InvalidParameter
Definition: core-exceptions.hpp:47
helics::RegistrationFailure
Definition: core-exceptions.hpp:84
helics
the main namespace for the helics co-simulation library User functions will be in the helics namespac...
Definition: AsyncFedCallInfo.hpp:14