[Libreoffice-commits] core.git: include/tools

Noel Grandin (via logerrit) logerrit at kemper.freedesktop.org
Fri Jun 14 07:11:45 UTC 2019


 include/tools/diagnose_ex.h |   30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

New commits:
commit 6ed829ab3b6233acfb1a7b5ec3412cf5a56ef8f2
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Thu Jun 13 11:56:46 2019 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Fri Jun 14 09:10:48 2019 +0200

    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 at collabora.co.uk>

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: */


More information about the Libreoffice-commits mailing list