From 7c2782366b479ed696a6361a481833284a4f0b62 Mon Sep 17 00:00:00 2001 From: Megvii Engine Team Date: Mon, 6 Jul 2020 15:20:02 +0800 Subject: [PATCH] feat(core): redact exception messages if logging is disabled GitOrigin-RevId: 1d6bda2380ca3853ada488236cd81845550e786e --- src/core/include/megbrain/common.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/core/include/megbrain/common.h b/src/core/include/megbrain/common.h index 42b253ae..af32f04e 100644 --- a/src/core/include/megbrain/common.h +++ b/src/core/include/megbrain/common.h @@ -84,9 +84,13 @@ void __on_exception_throw__(const std::exception &exc) MGB_CATCH(..., {_stmt; throw; }) \ _stmt +#if MGB_ENABLE_LOGGING +//! throw exception with given message +#define mgb_throw(_exc, _msg...) mgb_throw_raw(_exc(::mgb::ssprintf(_msg))) +#else //! throw exception with given message -#define mgb_throw(_exc, _msg...) \ - mgb_throw_raw(_exc(::mgb::ssprintf(_msg))) \ +#define mgb_throw(_exc, _msg...) mgb_throw_raw(_exc("")) +#endif //! throw exception with given message if condition is true #define mgb_throw_if(_cond, _exc, _msg...) \ -- GitLab