helics  3.5.2
core-exceptions.hpp
Go to the documentation of this file.
1 /*
2 Copyright (c) 2017-2024,
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 
30  public:
31  explicit FunctionExecutionFailure(
32  std::string_view message = "HELICS execution failure") noexcept: HelicsException(message)
33  {
34  }
35 };
36 
39  public:
40  explicit InvalidIdentifier(std::string_view message = "invalid identifier") noexcept:
41  HelicsException(message)
42  {
43  }
44 };
45 
48  public:
49  explicit InvalidParameter(std::string_view message = "invalid parameter") noexcept:
50  HelicsException(message)
51  {
52  }
53 };
54 
57  public:
58  explicit InvalidConversion(
59  std::string_view message = "unable to perform the requested conversion") noexcept:
60  HelicsException(message)
61  {
62  }
63 };
64 
67  public:
68  explicit InvalidFunctionCall(std::string_view message = "invalid function call") noexcept:
69  HelicsException(message)
70  {
71  }
72 };
73 
76  public:
77  explicit ConnectionFailure(std::string_view message = "failed to connect") noexcept:
78  HelicsException(message)
79  {
80  }
81 };
82 
85  public:
86  explicit RegistrationFailure(std::string_view message = "registration failure") noexcept:
87  HelicsException(message)
88  {
89  }
90 };
91 
94  public:
95  explicit HelicsSystemFailure(std::string_view message = "HELICS system failure") noexcept:
96  HelicsException(message)
97  {
98  }
99 };
100 
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
Definition: core-exceptions.hpp:75
Definition: core-exceptions.hpp:102
Definition: core-exceptions.hpp:29
Definition: core-exceptions.hpp:18
Definition: core-exceptions.hpp:93
Definition: core-exceptions.hpp:56
Definition: core-exceptions.hpp:66
Definition: core-exceptions.hpp:38
Definition: core-exceptions.hpp:47
Definition: core-exceptions.hpp:84
the main namespace for the helics co-simulation library User functions will be in the helics namespac...
Definition: AsyncFedCallInfo.hpp:14