From 299b8cc3d602928ab057aff34e0b93c029d64bc8 Mon Sep 17 00:00:00 2001 From: Norihiro Watanabe <norihiro.watanabe@ufz.de> Date: Fri, 23 Sep 2016 14:11:05 +0200 Subject: [PATCH] abort() in OGS_FATAL if OGS_FATAL_ABORT is defined --- BaseLib/Error.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/BaseLib/Error.h b/BaseLib/Error.h index f2894fd2066..1fa8bd9adf2 100644 --- a/BaseLib/Error.h +++ b/BaseLib/Error.h @@ -10,15 +10,30 @@ #ifndef BASELIB_ERROR_H #define BASELIB_ERROR_H +#ifdef OGS_FATAL_ABORT +#include <cstdlib> +#endif #include <stdexcept> +#ifdef OGS_FATAL_ABORT +#include <logog/include/logog.hpp> +#endif + #include "StringTools.h" #include "FileTools.h" #define OGS_STR(x) #x #define OGS_STRINGIFY(x) OGS_STR(x) #define OGS_LOCATION " at " + BaseLib::extractBaseName(__FILE__) + ", line " OGS_STRINGIFY(__LINE__) +#ifdef OGS_FATAL_ABORT +#define OGS_FATAL(fmt, ...)\ + {\ + ERR("%s", BaseLib::format(fmt, ##__VA_ARGS__).data());\ + std::abort();\ + } +#else #define OGS_FATAL(fmt, ...)\ throw std::runtime_error(BaseLib::format(fmt, ##__VA_ARGS__) + OGS_LOCATION); +#endif #endif //BASELIB_ERROR_H -- GitLab