-
Notifications
You must be signed in to change notification settings - Fork 658
Expand file tree
/
Copy patherror.h
More file actions
82 lines (63 loc) · 1.73 KB
/
Copy patherror.h
File metadata and controls
82 lines (63 loc) · 1.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#ifndef OPENMC_ERROR_H
#define OPENMC_ERROR_H
#include <cstring>
#include <sstream>
#include <string>
#include <fmt/format.h>
#include "openmc/capi.h"
#include "openmc/settings.h"
#if defined(__GNUC__) || defined(__clang__)
#define UNREACHABLE() __builtin_unreachable()
#else
#define UNREACHABLE() (void)0
#endif
namespace openmc {
inline void set_errmsg(const char* message)
{
std::strcpy(openmc_err_msg, message);
}
inline void set_errmsg(const std::string& message)
{
std::strcpy(openmc_err_msg, message.c_str());
}
inline void set_errmsg(const std::stringstream& message)
{
std::strcpy(openmc_err_msg, message.str().c_str());
}
[[noreturn]] void fatal_error(const std::string& message, int err = -1);
[[noreturn]] inline void fatal_error(const std::stringstream& message)
{
fatal_error(message.str());
}
[[noreturn]] inline void fatal_error(const char* message)
{
fatal_error(std::string {message, std::strlen(message)});
}
void warning(const std::string& message);
inline void warning(const std::stringstream& message)
{
warning(message.str());
}
void write_message(const std::string& message, int level = 0);
inline void write_message(const std::stringstream& message, int level)
{
write_message(message.str(), level);
}
template<typename... Params>
void write_message(
int level, const std::string& message, const Params&... fmt_args)
{
if (settings::verbosity >= level) {
write_message(fmt::format(fmt::runtime(message), fmt_args...));
}
}
template<typename... Params>
void write_message(const std::string& message, const Params&... fmt_args)
{
write_message(fmt::format(fmt::runtime(message), fmt_args...));
}
#ifdef OPENMC_MPI
extern "C" void abort_mpi(int code);
#endif
} // namespace openmc
#endif // OPENMC_ERROR_H