[PATCH] move DBG_UNHANDLED_EXCEPTION out of line

Noel Grandin (via Code Review) gerrit at gerrit.libreoffice.org
Mon May 20 23:41:11 PDT 2013


Hi,

I have submitted a patch for review:

    https://gerrit.libreoffice.org/3988

To pull it, you can do:

    git pull ssh://gerrit.libreoffice.org:29418/core refs/changes/88/3988/1

move DBG_UNHANDLED_EXCEPTION out of line

makes it easier to set a breakpoint on it.
Plus it's getting a little big to be a macro.

Change-Id: I2827aa3618ba966fbc85a4a56e0e794a55630730
---
M include/tools/diagnose_ex.h
M tools/source/debug/debug.cxx
2 files changed, 54 insertions(+), 39 deletions(-)



diff --git a/include/tools/diagnose_ex.h b/include/tools/diagnose_ex.h
index 261c0ae..a38b2d4 100644
--- a/include/tools/diagnose_ex.h
+++ b/include/tools/diagnose_ex.h
@@ -30,6 +30,8 @@
 #define OSL_UNUSED( expression ) \
     (void)(expression)
 
+
+
 #if OSL_DEBUG_LEVEL > 0
     #include <com/sun/star/configuration/CorruptedConfigurationException.hpp>
     #include <com/sun/star/task/ErrorCodeIOException.hpp>
@@ -39,51 +41,15 @@
     #include <boost/current_function.hpp>
     #include <typeinfo>
 
+    void DbgUnhandledException(const ::com::sun::star::uno::Any& caughtException, const char* currentFunction);
+
     /** reports a caught UNO exception via OSL diagnostics
 
         Note that whenever you use this, it might be an indicator that your error
         handling is not correct ....
     */
     #define DBG_UNHANDLED_EXCEPTION()   \
-        ::com::sun::star::uno::Any caught( ::cppu::getCaughtException() ); \
-        OString sMessage( "caught an exception!" ); \
-        sMessage += "\nin function:"; \
-        sMessage += BOOST_CURRENT_FUNCTION; \
-        sMessage += "\ntype: "; \
-        sMessage += OUStringToOString( caught.getValueTypeName(), osl_getThreadTextEncoding() ); \
-        ::com::sun::star::uno::Exception exception; \
-        caught >>= exception; \
-        if ( !exception.Message.isEmpty() ) \
-        { \
-            sMessage += "\nmessage: "; \
-            sMessage += OUStringToOString( exception.Message, osl_getThreadTextEncoding() ); \
-        } \
-        if ( exception.Context.is() ) \
-        { \
-            const char* pContext = typeid( *exception.Context.get() ).name(); \
-            sMessage += "\ncontext: "; \
-            sMessage += pContext; \
-        } \
-        { \
-            ::com::sun::star::configuration::CorruptedConfigurationException \
-                specialized; \
-            if ( caught >>= specialized ) \
-            { \
-                sMessage += "\ndetails: "; \
-                sMessage += OUStringToOString( \
-                    specialized.Details, osl_getThreadTextEncoding() ); \
-            } \
-        } \
-        { \
-            ::com::sun::star::task::ErrorCodeIOException specialized; \
-            if ( caught >>= specialized ) \
-            { \
-                sMessage += "\ndetails: "; \
-                sMessage += OString::valueOf( specialized.ErrCode ); \
-            } \
-        } \
-        sMessage += "\n"; \
-        OSL_ENSURE( false, sMessage.getStr() )
+        DbgUnhandledException( ::cppu::getCaughtException(), BOOST_CURRENT_FUNCTION);
 
 #else   // OSL_DEBUG_LEVEL
     #define DBG_UNHANDLED_EXCEPTION()
diff --git a/tools/source/debug/debug.cxx b/tools/source/debug/debug.cxx
index 104353b..eec15eb 100644
--- a/tools/source/debug/debug.cxx
+++ b/tools/source/debug/debug.cxx
@@ -42,6 +42,7 @@
 #include <vector>
 
 #include <osl/diagnose.h>
+#include <tools/diagnose_ex.h>
 
 #ifdef DBG_UTIL
 
@@ -1585,4 +1586,52 @@
 
 #endif
 
+
+#if OSL_DEBUG_LEVEL > 0
+
+void DbgUnhandledException(const css::uno::Any & caught, const char* currentFunction)
+{
+        OString sMessage( "caught an exception!" );
+        sMessage += "\nin function:";
+        sMessage += currentFunction;
+        sMessage += "\ntype: ";
+        sMessage += OUStringToOString( caught.getValueTypeName(), osl_getThreadTextEncoding() );
+        ::com::sun::star::uno::Exception exception;
+        caught >>= exception;
+        if ( !exception.Message.isEmpty() )
+        {
+            sMessage += "\nmessage: ";
+            sMessage += OUStringToOString( exception.Message, osl_getThreadTextEncoding() );
+        }
+        if ( exception.Context.is() )
+        {
+            const char* pContext = typeid( *exception.Context.get() ).name();
+            sMessage += "\ncontext: ";
+            sMessage += pContext;
+        }
+        {
+            ::com::sun::star::configuration::CorruptedConfigurationException
+                specialized;
+            if ( caught >>= specialized )
+            {
+                sMessage += "\ndetails: ";
+                sMessage += OUStringToOString(
+                    specialized.Details, osl_getThreadTextEncoding() );
+            }
+        }
+        {
+            ::com::sun::star::task::ErrorCodeIOException specialized;
+            if ( caught >>= specialized )
+            {
+                sMessage += "\ndetails: ";
+                sMessage += OString::valueOf( specialized.ErrCode );
+            }
+        }
+        sMessage += "\n";
+        OSL_ENSURE( false, sMessage.getStr() );
+}
+
+#endif  // OSL_DEBUG_LEVEL
+
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

-- 
To view, visit https://gerrit.libreoffice.org/3988
To unsubscribe, visit https://gerrit.libreoffice.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I2827aa3618ba966fbc85a4a56e0e794a55630730
Gerrit-PatchSet: 1
Gerrit-Project: core
Gerrit-Branch: master
Gerrit-Owner: Noel Grandin <noelgrandin at gmail.com>



More information about the LibreOffice mailing list