helics 3.7.0
Loading...
Searching...
No Matches
helicsExceptions.hpp
1/*
2Copyright (c) 2017-2026,
3Battelle Memorial Institute; Lawrence Livermore National Security, LLC; Alliance for Energy
4Innovation LLC. See the top-level NOTICE for additional details. All rights reserved.
5SPDX-License-Identifier: BSD-3-Clause
6*/
7
8#ifndef HELICS_CPP98_EXCEPTIONS_HPP_
9#define HELICS_CPP98_EXCEPTIONS_HPP_
10#pragma once
11
12#include "config.hpp"
13#include "helics/helics.h"
14
15#include <stdexcept>
16
17namespace helicscpp {
19class HelicsException: public std::runtime_error {
20 public:
25 explicit HelicsException(int error_code, const char* errorString):
26 std::runtime_error(errorString), eCode(error_code)
27 {
28 }
30 HELICS_NODISCARD int errorCode() const { return eCode; }
31
32 private:
33 int eCode;
34};
35
39 public:
45 ~hThrowOnError() HELICS_THROWS_EXCEPTION
46 {
47 if (eObj.error_code != 0) {
48 throw HelicsException(eObj.error_code, eObj.message);
49 }
50 }
52 operator HelicsError*() { return &eObj; }
53
54 private:
55 HelicsError eObj;
56};
57} // namespace helicscpp
58
59#endif /*HELICS_CPP98_EXCEPTIONS_HPP_*/
Definition helicsExceptions.hpp:19
HELICS_NODISCARD int errorCode() const
Definition helicsExceptions.hpp:30
HelicsException(int error_code, const char *errorString)
Definition helicsExceptions.hpp:25
Definition helicsExceptions.hpp:38
hThrowOnError()
Definition helicsExceptions.hpp:41
~hThrowOnError() HELICS_THROWS_EXCEPTION
Definition helicsExceptions.hpp:45
HelicsError helicsErrorInitialize(void)
Definition helicsExport.cpp:60
Definition cpp98/Broker.hpp:18
STL namespace.
Definition api-data.h:179
const char * message
Definition api-data.h:181
int32_t error_code
Definition api-data.h:180