OGS 6.2.1-499-g3b941532c.dirty.20191012113459
Error.h
Go to the documentation of this file.
1 
11 #pragma once
12 
13 #ifdef OGS_FATAL_ABORT
14 
15 #include <cstdlib>
16 #include <logog/include/logog.hpp>
17 
18 namespace BaseLib
19 {
20 namespace detail
21 {
22 template <typename Msg>
23 [[noreturn]]
24  bool error_impl(Msg&& msg)
25 {
26  ERR("%s", msg.data());
27  std::abort();
28 }
29 
30 } // namespace detail
31 
32 } // namespace BaseLib
33 
34 #else // OGS_FATAL_ABORT
35 
36 #include <stdexcept>
37 
38 namespace BaseLib
39 {
40 namespace detail
41 {
42 template <typename Msg>
43 [[noreturn]]
44  bool error_impl(Msg&& msg)
45 {
46  throw std::runtime_error(std::forward<Msg>(msg));
47 }
48 
49 } // namespace detail
50 
51 } // namespace BaseLib
52 
53 #endif // OGS_FATAL_ABORT
54 
55 #include "FileTools.h"
56 #include "StringTools.h"
57 
58 #define OGS_STR(x) #x
59 #define OGS_STRINGIFY(x) OGS_STR(x)
60 #define OGS_LOCATION \
61  (" at " + BaseLib::extractBaseName(__FILE__) + \
62  ", line " OGS_STRINGIFY(__LINE__))
63 
64 #define OGS_FATAL(fmt, ...) \
65  BaseLib::detail::error_impl(BaseLib::format(fmt, ##__VA_ARGS__) + \
66  OGS_LOCATION)
Definition of string helper functions.
bool error_impl(Msg &&msg)
Definition: Error.h:44
Functionality to build different search length algorithm objects from given config.
Filename manipulation routines.