hp-FEM
Adaptive hp-FEM suite for nano-optics
Loading...
Searching...
No Matches
error.hpp
Go to the documentation of this file.
1#pragma once
5#include <stdexcept>
6#include <string>
7
8namespace hpfem {
9
10class Error : public std::runtime_error {
11 public:
12 using std::runtime_error::runtime_error;
13};
14
15class InvalidArgument : public Error {
16 public:
17 using Error::Error;
18};
19
20class NotImplemented : public Error {
21 public:
22 using Error::Error;
23};
24
28 public:
29 using NotImplemented::NotImplemented;
30};
31
32[[noreturn]] void assertion_failed(const char* expr, const char* file, int line,
33 const std::string& msg);
34
35} // namespace hpfem
36
37#if defined(HPFEM_ENABLE_ASSERTS)
38// Positive test on purpose: `if (!(a && b))` makes clang-tidy suggest De Morgan at
39// every call site; `if (cond) {} else` does not.
40#define HPFEM_ASSERT(cond, msg) \
41 do { \
42 if (cond) { \
43 } else { \
44 ::hpfem::assertion_failed(#cond, __FILE__, __LINE__, (msg)); \
45 } \
46 } while (false)
47#else
48#define HPFEM_ASSERT(cond, msg) \
49 do { \
50 } while (false)
51#endif
Definition error.hpp:27
Definition error.hpp:10
Definition error.hpp:15
Definition error.hpp:20
Definition axisymmetric_estimator.hpp:39
void assertion_failed(const char *expr, const char *file, int line, const std::string &msg)