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

Eike Rathke erack at redhat.com
Fri Nov 25 15:27:06 UTC 2016


 include/tools/diagnose_ex.h     |    8 +++++++-
 tools/source/debug/debug.cxx    |    8 +++++++-
 xmloff/source/draw/ximpshap.cxx |   33 +++++++++++++++++----------------
 3 files changed, 31 insertions(+), 18 deletions(-)

New commits:
commit f780deb1e376f28a1c55cf4fb0381d6db2bd49cb
Author: Eike Rathke <erack at redhat.com>
Date:   Fri Nov 25 16:25:53 2016 +0100

    replace meaningless OSL_FAIL with DBG_UNHANDLED_EXCEPTION_WHEN
    
    Change-Id: I8aceb106339d879455bd96b2f84b54306f13d062

diff --git a/xmloff/source/draw/ximpshap.cxx b/xmloff/source/draw/ximpshap.cxx
index d8b69cd..5c39e8f 100644
--- a/xmloff/source/draw/ximpshap.cxx
+++ b/xmloff/source/draw/ximpshap.cxx
@@ -59,6 +59,7 @@
 
 #include <sax/tools/converter.hxx>
 #include <comphelper/sequence.hxx>
+#include <tools/diagnose_ex.h>
 
 #include "PropertySetMerger.hxx"
 #include <xmloff/families.hxx>
@@ -330,7 +331,7 @@ void SdXMLShapeContext::addGluePoint( const uno::Reference< xml::sax::XAttribute
         }
         catch(const uno::Exception&)
         {
-            OSL_FAIL( "exception during setting of glue points!");
+            DBG_UNHANDLED_EXCEPTION_WHEN( "during setting of glue points");
         }
     }
 }
@@ -402,7 +403,7 @@ void SdXMLShapeContext::EndElement()
     }
     catch(const Exception&)
     {
-        OSL_FAIL("xmloff::SdXMLShapeContext::EndElement(), exception caught while setting hyperlink!");
+        DBG_UNHANDLED_EXCEPTION_WHEN("while setting hyperlink");
     }
 
     if( mxLockable.is() )
@@ -444,7 +445,7 @@ void SdXMLShapeContext::AddShape(uno::Reference< drawing::XShape >& xShape)
         }
         catch(const Exception&)
         {
-            OSL_FAIL( "SdXMLShapeContext::AddShape(), exception caught!" );
+            DBG_UNHANDLED_EXCEPTION_WHEN( "while setting visible or printable" );
         }
 
         if(!mbTemporaryShape && (!GetImport().HasTextImport()
@@ -679,7 +680,7 @@ void SdXMLShapeContext::SetStyle( bool bSupportsStyle /* = true */)
                 }
                 catch(const uno::Exception&)
                 {
-                    OSL_FAIL( "could not find style for shape!" );
+                    DBG_UNHANDLED_EXCEPTION_WHEN( "finding style for shape" );
                 }
             }
 
@@ -692,7 +693,7 @@ void SdXMLShapeContext::SetStyle( bool bSupportsStyle /* = true */)
                 }
                 catch(const uno::Exception&)
                 {
-                    OSL_FAIL( "could not find style for shape!" );
+                    DBG_UNHANDLED_EXCEPTION_WHEN( "setting style for shape" );
                 }
             }
 
@@ -1055,7 +1056,7 @@ void SdXMLRectShapeContext::StartElement(const uno::Reference< xml::sax::XAttrib
                 }
                 catch(const uno::Exception&)
                 {
-                    OSL_FAIL( "exception during setting of corner radius!");
+                    DBG_UNHANDLED_EXCEPTION_WHEN( "setting corner radius");
                 }
             }
         }
@@ -1721,7 +1722,7 @@ void SdXMLTextBoxShapeContext::StartElement(const uno::Reference< xml::sax::XAtt
                 }
                 catch(const uno::Exception&)
                 {
-                    OSL_FAIL( "exception during setting of corner radius!");
+                    DBG_UNHANDLED_EXCEPTION_WHEN( "setting corner radius");
                 }
             }
         }
@@ -1738,7 +1739,7 @@ void SdXMLTextBoxShapeContext::StartElement(const uno::Reference< xml::sax::XAtt
                 }
                 catch(const uno::Exception&)
                 {
-                    OSL_FAIL( "exception during setting of name of next chain link!");
+                    DBG_UNHANDLED_EXCEPTION_WHEN( "setting name of next chain link");
                 }
             }
         }
@@ -2375,7 +2376,7 @@ void SdXMLCaptionShapeContext::StartElement(const uno::Reference< xml::sax::XAtt
                 }
                 catch(const uno::Exception&)
                 {
-                    OSL_FAIL( "exception during setting of corner radius!");
+                    DBG_UNHANDLED_EXCEPTION_WHEN( "setting corner radius");
                 }
             }
         }
@@ -3445,7 +3446,7 @@ void SdXMLFrameShapeContext::removeGraphicFromImportContext(const SvXMLImportCon
         }
         catch( uno::Exception& )
         {
-            OSL_FAIL( "Error in cleanup of multiple graphic object import (!)" );
+            DBG_UNHANDLED_EXCEPTION_WHEN( "Error in cleanup of multiple graphic object import." );
         }
     }
 }
@@ -3474,7 +3475,7 @@ OUString SdXMLFrameShapeContext::getGraphicURLFromImportContext(const SvXMLImpor
         }
         catch( uno::Exception& )
         {
-            OSL_FAIL( "Error in cleanup of multiple graphic object import (!)" );
+            DBG_UNHANDLED_EXCEPTION_WHEN( "Error in cleanup of multiple graphic object import." );
         }
     }
 
@@ -3769,7 +3770,7 @@ void SdXMLCustomShapeContext::StartElement( const uno::Reference< xml::sax::XAtt
         }
         catch(const uno::Exception&)
         {
-            OSL_FAIL( "could not set enhanced customshape geometry" );
+            DBG_UNHANDLED_EXCEPTION_WHEN( "setting enhanced customshape geometry" );
         }
         SdXMLShapeContext::StartElement(xAttrList);
     }
@@ -3852,7 +3853,7 @@ void SdXMLCustomShapeContext::EndElement()
         }
         catch(const uno::Exception&)
         {
-            OSL_FAIL( "could not set enhanced customshape geometry" );
+            DBG_UNHANDLED_EXCEPTION_WHEN( "setting enhanced customshape geometry" );
         }
 
         sal_Int32 nUPD;
@@ -3891,7 +3892,7 @@ void SdXMLCustomShapeContext::EndElement()
     }
     catch(const uno::Exception&)
     {
-        OSL_FAIL("could not flush after load");
+        DBG_UNHANDLED_EXCEPTION_WHEN("flushing after load");
     }
 }
 
@@ -3979,7 +3980,7 @@ void SdXMLTableShapeContext::StartElement( const css::uno::Reference< css::xml::
             }
             catch(const Exception&)
             {
-                OSL_FAIL("SdXMLTableShapeContext::StartElement(), exception caught!");
+                DBG_UNHANDLED_EXCEPTION();
             }
 
             const XMLPropertyMapEntry* pEntry = &aXMLTableShapeAttributes[0];
@@ -3992,7 +3993,7 @@ void SdXMLTableShapeContext::StartElement( const css::uno::Reference< css::xml::
                 }
                 catch(const Exception&)
                 {
-                    OSL_FAIL("SdXMLTableShapeContext::StartElement(), exception caught!");
+                    DBG_UNHANDLED_EXCEPTION();
                 }
             }
         }
commit 6c60aa313c0598d9136f0bf6e2adc60654fc28d0
Author: Eike Rathke <erack at redhat.com>
Date:   Fri Nov 25 16:13:03 2016 +0100

    introduce DBG_UNHANDLED_EXCEPTION_WHEN for calls with an explanatory message
    
    Change-Id: Ic80f2ed2c0fdff20d1ee1968bec2840bf914fb5e

diff --git a/include/tools/diagnose_ex.h b/include/tools/diagnose_ex.h
index bd0ec88..b3db8eb 100644
--- a/include/tools/diagnose_ex.h
+++ b/include/tools/diagnose_ex.h
@@ -27,7 +27,9 @@
 
 #include <tools/toolsdllapi.h>
 
-TOOLS_DLLPUBLIC void DbgUnhandledException(const css::uno::Any& caughtException, const char* currentFunction, const char* fileAndLineNo);
+TOOLS_DLLPUBLIC void DbgUnhandledException(const css::uno::Any& caughtException,
+        const char* currentFunction, const char* fileAndLineNo,
+        const char* explanatory = nullptr);
 
 #if OSL_DEBUG_LEVEL > 0
     #include <com/sun/star/configuration/CorruptedConfigurationException.hpp>
@@ -43,8 +45,12 @@ TOOLS_DLLPUBLIC void DbgUnhandledException(const css::uno::Any& caughtException,
     #define DBG_UNHANDLED_EXCEPTION()   \
         DbgUnhandledException( ::cppu::getCaughtException(), OSL_THIS_FUNC, SAL_DETAIL_WHERE);
 
+    #define DBG_UNHANDLED_EXCEPTION_WHEN(explain)   \
+        DbgUnhandledException( ::cppu::getCaughtException(), OSL_THIS_FUNC, SAL_DETAIL_WHERE, explain);
+
 #else   // OSL_DEBUG_LEVEL
     #define DBG_UNHANDLED_EXCEPTION()
+    #define DBG_UNHANDLED_EXCEPTION_WHEN(explain)
 #endif  // OSL_DEBUG_LEVEL
 
 /** This macro asserts the given condition (in debug mode), and throws
diff --git a/tools/source/debug/debug.cxx b/tools/source/debug/debug.cxx
index 1f67a6f..65850ce 100644
--- a/tools/source/debug/debug.cxx
+++ b/tools/source/debug/debug.cxx
@@ -76,10 +76,16 @@ void DbgTestSolarMutex()
 
 #endif
 
-void DbgUnhandledException(const css::uno::Any & caught, const char* currentFunction, const char* fileAndLineNo)
+void DbgUnhandledException(const css::uno::Any & caught, const char* currentFunction, const char* fileAndLineNo,
+        const char* explanatory)
 {
         OString sMessage( "DBG_UNHANDLED_EXCEPTION in " );
         sMessage += currentFunction;
+        if (explanatory)
+        {
+            sMessage += "\n    when: ";
+            sMessage += explanatory;
+        }
         sMessage += "\n    type: ";
         sMessage += OUStringToOString( caught.getValueTypeName(), osl_getThreadTextEncoding() );
         css::uno::Exception exception;


More information about the Libreoffice-commits mailing list