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