Skip to content
Snippets Groups Projects
Commit 89dd4b9c authored by Christoph Lehmann's avatar Christoph Lehmann
Browse files

[BL] enable SOME_EXPRESSION && OGS_FATAL(...)

parent d8b8c54e
No related branches found
No related tags found
No related merge requests found
...@@ -13,25 +13,51 @@ ...@@ -13,25 +13,51 @@
#include <cstdlib> #include <cstdlib>
#include <logog/include/logog.hpp> #include <logog/include/logog.hpp>
#include "StringTools.h"
#define OGS_FATAL(fmt, ...)\ namespace BaseLib
{\ {
ERR("%s", BaseLib::format(fmt, ##__VA_ARGS__).data());\ namespace detail
std::abort();\ {
} template <typename Msg>
[[noreturn]] 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>
namespace BaseLib
{
namespace detail
{
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
#include "FileTools.h" #include "FileTools.h"
#include "StringTools.h" #include "StringTools.h"
#define OGS_STR(x) #x #define OGS_STR(x) #x
#define OGS_STRINGIFY(x) OGS_STR(x) #define OGS_STRINGIFY(x) OGS_STR(x)
#define OGS_LOCATION " at " + BaseLib::extractBaseName(__FILE__) + ", line " OGS_STRINGIFY(__LINE__) #define OGS_LOCATION \
" at " + BaseLib::extractBaseName(__FILE__) + \
#define OGS_FATAL(fmt, ...)\ ", line " OGS_STRINGIFY(__LINE__)
throw std::runtime_error(BaseLib::format(fmt, ##__VA_ARGS__) + OGS_LOCATION);
#endif // OGS_FATAL_ABORT #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