diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2019-06-13 11:56:46 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2019-06-14 09:10:48 +0200 |
commit | 6ed829ab3b6233acfb1a7b5ec3412cf5a56ef8f2 (patch) | |
tree | 2c158b3b0feaa925d00f1dab645abf179ad97e7a /include/tools | |
parent | 31b44f010557c43d8b02cc3be590ed1629bf1ca5 (diff) |
add TOOLS_WARN_EXCEPTION,etc macros
to be used for nicer logging of exceptions, along with upcoming clang
plugin
Change-Id: I028c31ec329652e4842136528605b4cceaae946d
Reviewed-on: https://gerrit.libreoffice.org/73949
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'include/tools')
-rw-r--r-- | include/tools/diagnose_ex.h | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/include/tools/diagnose_ex.h b/include/tools/diagnose_ex.h index 596e44c4694d..d37b7e99b368 100644 --- a/include/tools/diagnose_ex.h +++ b/include/tools/diagnose_ex.h @@ -133,6 +133,36 @@ inline css::uno::Any DbgGetCaughtException() */ TOOLS_DLLPUBLIC OString exceptionToString(css::uno::Any const & caughtEx); +/** + Logs an message along with a nicely formatted version of the current exception. + This must be called as the FIRST thing in a catch block. +*/ +#define TOOLS_WARN_EXCEPTION(area, stream) \ + do { \ + css::uno::Any tools_warn_exception( cppu::getCaughtException() ); \ + SAL_WARN(area, stream << " " << exceptionToString(tools_warn_exception)); \ + } while (false) + +/** + Logs an message along with a nicely formatted version of the current exception. + This must be called as the FIRST thing in a catch block. +*/ +#define TOOLS_WARN_EXCEPTION_IF(cond, area, stream) \ + do { \ + css::uno::Any tools_warn_exception( cppu::getCaughtException() ); \ + SAL_WARN_IF(cond, area, stream << " " << exceptionToString(tools_warn_exception)); \ + } while (false) + +/** + Logs an message along with a nicely formatted version of the current exception. + This must be called as the FIRST thing in a catch block. +*/ +#define TOOLS_INFO_EXCEPTION(area, stream) \ + do { \ + css::uno::Any tools_warn_exception( cppu::getCaughtException() ); \ + SAL_WARN(area, stream << " " << exceptionToString(tools_warn_exception)); \ + } while (false) + #endif /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |