Skip to content
Snippets Groups Projects
Commit 72b42ef6 authored by Dmitri Naumov's avatar Dmitri Naumov
Browse files

[BL] Replace OGS_FATAL macro with spdlog version.

parent ffeae743
No related branches found
No related tags found
No related merge requests found
...@@ -10,57 +10,23 @@ ...@@ -10,57 +10,23 @@
#pragma once #pragma once
#ifdef OGS_FATAL_ABORT
#include <cstdlib> #include <cstdlib>
#include "Logging.h" #include "Logging.h"
namespace BaseLib #ifdef OGS_FATAL_ABORT
{ #define OGS_FATAL(...) \
namespace detail { \
{ BaseLib::console->critical("{}:{} {}() ", __FILE__, __LINE__, \
template <typename Msg> __FUNCTION__, fmt::format(__VA_ARGS__)); \
[[noreturn]] std::abort(); \
bool error_impl(Msg&& msg) }
{
ERR("{:s}", msg.data());
std::abort();
}
} // namespace detail
} // namespace BaseLib
#else // OGS_FATAL_ABORT #else // OGS_FATAL_ABORT
#include <stdexcept> #include <stdexcept>
#define OGS_FATAL(...) \
namespace BaseLib { \
{ BaseLib::console->critical("{}:{} {}() ", __FILE__, __LINE__, \
namespace detail __FUNCTION__, fmt::format(__VA_ARGS__)); \
{ throw std::runtime_error(fmt::format(__VA_ARGS__)); \
template <typename Msg> }
[[noreturn]]
bool error_impl(Msg&& msg)
{
throw std::runtime_error(std::forward<Msg>(msg));
}
} // namespace detail
} // namespace BaseLib
#endif // OGS_FATAL_ABORT #endif // OGS_FATAL_ABORT
#include "FileTools.h"
#include "StringTools.h"
#define OGS_STR(x) #x
#define OGS_STRINGIFY(x) OGS_STR(x)
#define OGS_LOCATION \
(" at " + BaseLib::extractBaseName(__FILE__) + \
", line " OGS_STRINGIFY(__LINE__))
#define OGS_FATAL(fmt, ...) \
BaseLib::detail::error_impl(BaseLib::format(fmt, ##__VA_ARGS__) + \
OGS_LOCATION)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment