OGS
Error.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) OpenGeoSys Community (opengeosys.org)
2// SPDX-License-Identifier: BSD-3-Clause
3
4#pragma once
5
6#include <cstdlib>
7
8#include "Logging.h"
9
10#ifdef OGS_FATAL_ABORT
11#define OGS_FATAL(...) \
12 { \
13 BaseLib::console->critical("{}:{} {}() ", __FILE__, __LINE__, \
14 __FUNCTION__, fmt::format(__VA_ARGS__)); \
15 std::abort(); \
16 }
17#else // OGS_FATAL_ABORT
18#include <stdexcept>
19#define OGS_FATAL(...) \
20 { \
21 auto const formatted_va_args = fmt::format(__VA_ARGS__); \
22 BaseLib::console->critical("{}:{} {}() ", __FILE__, __LINE__, \
23 __FUNCTION__, formatted_va_args); \
24 throw std::runtime_error(formatted_va_args); \
25 }
26#endif // OGS_FATAL_ABORT