[Libreoffice-commits] core.git: unotools/source

Stephan Bergmann sbergman at redhat.com
Wed Jun 15 09:41:13 UTC 2016


 unotools/source/config/configitem.cxx |  156 +++++++++++++++++++++++-----------
 1 file changed, 106 insertions(+), 50 deletions(-)

New commits:
commit 6a5c8d09b5285e44795fdb82f161a1aea275e436
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Wed Jun 15 11:40:40 2016 +0200

    Use SAL_WARN on swallowed exceptions
    
    Change-Id: If4d7b51de338c026b3308a733c8f4a41478158b2

diff --git a/unotools/source/config/configitem.cxx b/unotools/source/config/configitem.cxx
index 083e98d..694acb7 100644
--- a/unotools/source/config/configitem.cxx
+++ b/unotools/source/config/configitem.cxx
@@ -54,22 +54,6 @@ using namespace com::sun::star::configuration;
 
 #include <cppuhelper/implbase.hxx>
 
-#ifdef DBG_UTIL
-static inline void lcl_CFG_DBG_EXCEPTION(const sal_Char* cText, const Exception& rEx)
-{
-    OString sMsg(cText);
-    sMsg += OString(rEx.Message.getStr(), rEx.Message.getLength(), RTL_TEXTENCODING_ASCII_US);
-    OSL_FAIL(sMsg.getStr());
-}
-#define CATCH_INFO(a) \
-catch(const Exception& rEx)   \
-{                       \
-    lcl_CFG_DBG_EXCEPTION(a, rEx);\
-}
-#else
-    #define CATCH_INFO(a) catch(const Exception&){}
-#endif
-
 /*
     The ConfigChangeListener_Impl receives notifications from the configuration about changes that
     have happened. It forwards this notification to the ConfigItem it knows a pParent by calling its
@@ -520,14 +504,24 @@ bool ConfigItem::PutProperties( const Sequence< OUString >& rNames,
                     xTopNodeReplace->replaceByName(sProperty, pValues[i]);
                 }
             }
-            CATCH_INFO("Exception from PutProperties: ");
+            catch (css::uno::Exception & e)
+            {
+                SAL_WARN(
+                    "unotools.config",
+                    "Exception from PutProperties: " << e.Message);
+            }
         }
         try
         {
             Reference<XChangesBatch> xBatch(xHierarchyAccess, UNO_QUERY);
             xBatch->commitChanges();
         }
-        CATCH_INFO("Exception from commitChanges(): ")
+        catch (css::uno::Exception & e)
+        {
+            SAL_WARN(
+                "unotools.config",
+                "Exception from commitChanges(): " << e.Message);
+        }
     }
 
     return bRet;
@@ -602,7 +596,13 @@ static void lcl_normalizeLocalNames(Sequence< OUString >& _rNames, ConfigNameFor
                     {
                         pNames[i] = xFormatter->composeHierarchicalName(pNames[i]);
                     }
-                    CATCH_INFO("Exception from composeHierarchicalName(): ")
+                    catch (css::uno::Exception & e)
+                    {
+                        SAL_WARN(
+                            "unotools.config",
+                            "Exception from composeHierarchicalName(): "
+                                << e.Message);
+                    }
                 }
                 break;
             }
@@ -650,7 +650,12 @@ static void lcl_normalizeLocalNames(Sequence< OUString >& _rNames, ConfigNameFor
                 {
                     pNames[i] = xEscaper->unescapeString(pNames[i]);
                 }
-                CATCH_INFO("Exception from unescapeString(): ")
+                catch (css::uno::Exception & e)
+                {
+                    SAL_WARN(
+                        "unotools.config",
+                        "Exception from unescapeString(): " << e.Message);
+                }
             }
         }
         break;
@@ -688,7 +693,12 @@ Sequence< OUString > ConfigItem::GetNodeNames(const OUString& rNode, ConfigNameF
             }
 
         }
-        CATCH_INFO("Exception from GetNodeNames: ");
+        catch (css::uno::Exception & e)
+        {
+            SAL_WARN(
+                "unotools.config",
+                "Exception from GetNodeNames: " << e.Message);
+        }
     }
     return aRet;
 }
@@ -721,12 +731,21 @@ bool ConfigItem::ClearNodeSet(const OUString& rNode)
                 {
                     xCont->removeByName(pNames[i]);
                 }
-                CATCH_INFO("Exception from removeByName(): ")
+                catch (css::uno::Exception & e)
+                {
+                    SAL_WARN(
+                        "unotools.config",
+                         "Exception from removeByName(): " << e.Message);
+                }
             }
             xBatch->commitChanges();
             bRet = true;
         }
-        CATCH_INFO("Exception from ClearNodeSet")
+        catch (css::uno::Exception & e)
+        {
+            SAL_WARN(
+                "unotools.config", "Exception from ClearNodeSet" << e.Message);
+        }
     }
     return bRet;
 }
@@ -760,10 +779,20 @@ bool ConfigItem::ClearNodeElements(const OUString& rNode, Sequence< OUString >&
                 Reference<XChangesBatch> xBatch(xHierarchyAccess, UNO_QUERY);
                 xBatch->commitChanges();
             }
-            CATCH_INFO("Exception from commitChanges(): ")
+            catch (css::uno::Exception & e)
+            {
+                SAL_WARN(
+                    "unotools.config",
+                    "Exception from commitChanges(): " << e.Message);
+            }
             bRet = true;
         }
-        CATCH_INFO("Exception from GetNodeNames: ")
+        catch (css::uno::Exception & e)
+        {
+            SAL_WARN(
+                "unotools.config",
+                "Exception from GetNodeNames: " << e.Message);
+        }
     }
     return bRet;
 }
@@ -848,7 +877,12 @@ bool ConfigItem::SetSetProperties(
                 {
                     xBatch->commitChanges();
                 }
-                CATCH_INFO("Exception from commitChanges(): ")
+                catch (css::uno::Exception & e)
+                {
+                    SAL_WARN(
+                        "unotools.config",
+                        "Exception from commitChanges(): " << e.Message);
+                }
 
                 const PropertyValue* pProperties = rValues.getConstArray();
 
@@ -884,19 +918,22 @@ bool ConfigItem::SetSetProperties(
                         OSL_ENSURE( xHierarchyAccess->hasByHierarchicalName(pValues[nValue].Name),
                             "Invalid config path" );
                     }
-                    CATCH_INFO("Exception form insert/replaceByName(): ")
+                    catch (css::uno::Exception & e)
+                    {
+                        SAL_WARN(
+                            "unotools.config",
+                            "Exception form insert/replaceByName(): "
+                                << e.Message);
+                    }
                 }
                 xBatch->commitChanges();
             }
         }
-#ifdef DBG_UTIL
         catch (const Exception& rEx)
         {
-            lcl_CFG_DBG_EXCEPTION("Exception from SetSetProperties: ", rEx);
-#else
-        catch (const Exception&)
-        {
-#endif
+            SAL_WARN(
+                "unotools.config",
+                "Exception from SetSetProperties: " << rEx.Message);
             bRet = false;
         }
     }
@@ -972,7 +1009,12 @@ bool ConfigItem::ReplaceSetProperties(
                     }
                 }
                 try { xBatch->commitChanges(); }
-                CATCH_INFO("Exception from commitChanges(): ")
+                catch (css::uno::Exception & e)
+                {
+                    SAL_WARN(
+                        "unotools.config",
+                        "Exception from commitChanges(): " << e.Message);
+                }
             }
 
             if(xFac.is()) // !isSimpleValueSet
@@ -988,7 +1030,12 @@ bool ConfigItem::ReplaceSetProperties(
                     }
                 }
                 try { xBatch->commitChanges(); }
-                CATCH_INFO("Exception from commitChanges(): ")
+                catch (css::uno::Exception & e)
+                {
+                    SAL_WARN(
+                        "unotools.config",
+                        "Exception from commitChanges(): " << e.Message);
+                }
 
                 const PropertyValue* pProperties = rValues.getConstArray();
 
@@ -1022,19 +1069,22 @@ bool ConfigItem::ReplaceSetProperties(
                         else
                             xCont->insertByName(sSubNode, pValues[nValue].Value);
                     }
-                    CATCH_INFO("Exception from insert/replaceByName(): ");
+                    catch (css::uno::Exception & e)
+                    {
+                        SAL_WARN(
+                            "unotools.config",
+                            "Exception from insert/replaceByName(): "
+                                << e.Message);
+                    }
                 }
                 xBatch->commitChanges();
             }
         }
-#ifdef DBG_UTIL
         catch (const Exception& rEx)
         {
-            lcl_CFG_DBG_EXCEPTION("Exception from ReplaceSetProperties: ", rEx);
-#else
-        catch (const Exception&)
-        {
-#endif
+            SAL_WARN(
+                "unotools.config",
+                "Exception from ReplaceSetProperties: " << rEx.Message);
             bRet = false;
         }
     }
@@ -1076,7 +1126,12 @@ bool ConfigItem::AddNode(const OUString& rNode, const OUString& rNewNode)
                 {
                     xBatch->commitChanges();
                 }
-                CATCH_INFO("Exception from commitChanges(): ")
+                catch (css::uno::Exception & e)
+                {
+                    SAL_WARN(
+                        "unotools.config",
+                        "Exception from commitChanges(): " << e.Message);
+                }
             }
             else
             {
@@ -1086,18 +1141,19 @@ bool ConfigItem::AddNode(const OUString& rNode, const OUString& rNewNode)
                     if(!xCont->hasByName(rNewNode))
                         xCont->insertByName(rNewNode, Any());
                 }
-                CATCH_INFO("Exception from AddNode(): ")
+                catch (css::uno::Exception & e)
+                {
+                    SAL_WARN(
+                        "unotools.config",
+                        "Exception from AddNode(): " << e.Message);
+                }
             }
             xBatch->commitChanges();
         }
-#ifdef DBG_UTIL
         catch (const Exception& rEx)
         {
-            lcl_CFG_DBG_EXCEPTION("Exception from AddNode(): ", rEx);
-#else
-        catch (const Exception&)
-        {
-#endif
+            SAL_WARN(
+                "unotools.config", "Exception from AddNode(): " << rEx.Message);
             bRet = false;
         }
     }


More information about the Libreoffice-commits mailing list