Print more info when exception occurred

This commit is contained in:
Nomango 2020-05-17 20:16:56 +08:00
parent a2e3a1ea8c
commit 7cfccdbf3c
1 changed files with 8 additions and 5 deletions

View File

@ -20,12 +20,14 @@
#pragma once #pragma once
#include <kiwano/core/Common.h> #include <kiwano/core/Common.h>
#include <kiwano/core/Logger.h>
#include <stdexcept> #include <stdexcept>
#include <system_error> #include <system_error>
#define KGE_THROW(MESSAGE) \ #define KGE_THROW(MESSAGE) \
do \ do \
{ \ { \
KGE_ERROR("An exception occurred: %s", MESSAGE); \
kiwano::StackTracer().Print(); \ kiwano::StackTracer().Print(); \
throw kiwano::RuntimeError(MESSAGE); \ throw kiwano::RuntimeError(MESSAGE); \
} while (0) } while (0)
@ -33,6 +35,7 @@
#define KGE_THROW_SYSTEM_ERROR(ERRCODE, MESSAGE) \ #define KGE_THROW_SYSTEM_ERROR(ERRCODE, MESSAGE) \
do \ do \
{ \ { \
KGE_ERROR("An exception occurred (%#x): %s", ERRCODE, MESSAGE); \
kiwano::StackTracer().Print(); \ kiwano::StackTracer().Print(); \
throw kiwano::SystemError(std::error_code(kiwano::error_enum(ERRCODE)), MESSAGE); \ throw kiwano::SystemError(std::error_code(kiwano::error_enum(ERRCODE)), MESSAGE); \
} while (0) } while (0)