Cholla
3.0.1-dev
Cholla - Massively parallel hydro on GPUs
Loading...
Searching...
No Matches
src
utils
error_handling.h
1
#ifndef ERROR_HANDLING_CHOLLA_H
2
#define ERROR_HANDLING_CHOLLA_H
3
#include <stdlib.h>
4
5
#include <optional>
6
#include <type_traits>
// std::false_type
7
8
#include "../global/global.h"
9
[[noreturn]]
void
chexit(
int
code);
10
35
template
<
class
...>
36
constexpr
std::false_type always_false{};
37
43
void
Check_Configuration(
Parameters
const
& P);
44
50
[[noreturn]]
void
Abort_With_Err_(
const
char
* func_name,
const
char
* file_name,
int
line_num,
const
char
* msg, ...);
51
52
/* __CHOLLA_PRETTY_FUNC__ is a magic constant like __LINE__ or __FILE__ that
53
* provides the name of the current function.
54
* - The C++11 standard requires that __func__ is provided on all platforms, but
55
* that only provides limited information (just the name of the function).
56
* - Where available, we prefer to use compiler-specific features that provide
57
* more information about the function (like the scope of the function & the
58
* the function signature).
59
*/
60
#ifdef __GNUG__
61
#define __CHOLLA_PRETTY_FUNC__ __PRETTY_FUNCTION__
62
#else
63
#define __CHOLLA_PRETTY_FUNC__ __func__
64
#endif
65
80
#define CHOLLA_ERROR(...) Abort_With_Err_(__CHOLLA_PRETTY_FUNC__, __FILE__, __LINE__, __VA_ARGS__)
81
96
#define CHOLLA_ASSERT(cond, ...) \
97
if (not(cond)) {
/* NOLINT */
\
98
Abort_With_Err_(__CHOLLA_PRETTY_FUNC__, __FILE__, __LINE__, __VA_ARGS__); \
99
}
100
111
template
<
typename
T>
112
[[gnu::always_inline]]
inline
T& get_or_abort(std::optional<T>& optional)
113
{
114
if
(optional.has_value()) {
115
return
optional.value();
116
}
117
CHOLLA_ERROR(
"the optional is empty"
);
118
}
119
120
#endif
/*ERROR_HANDLING_CHOLLA_H*/
Parameters
Definition
global.h:217
Generated by
1.9.8