Browse Source

feat(core): redact exception messages if logging is disabled

GitOrigin-RevId: 1d6bda2380
release-0.6
Megvii Engine Team 5 years ago
parent
commit
7c2782366b
1 changed files with 6 additions and 2 deletions
  1. +6
    -2
      src/core/include/megbrain/common.h

+ 6
- 2
src/core/include/megbrain/common.h View File

@@ -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...) \


Loading…
Cancel
Save