[Libreoffice-commits] core.git: cppuhelper/source cui/source

Stephan Bergmann sbergman at redhat.com
Wed Nov 2 09:34:19 UTC 2016


 cppuhelper/source/servicemanager.cxx |   10 ++++++++--
 cui/source/dialogs/scriptdlg.cxx     |   28 +++++++---------------------
 2 files changed, 15 insertions(+), 23 deletions(-)

New commits:
commit d2615f96acf1030ea888b2f24a9c5bf4db0d9f0e
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Wed Nov 2 10:33:49 2016 +0100

    Improve some error reporting
    
    Change-Id: Ibfdb0eeebec785438d46a0e8e6e9f4c847bfb807

diff --git a/cppuhelper/source/servicemanager.cxx b/cppuhelper/source/servicemanager.cxx
index a4267f9..f2c1a4c 100644
--- a/cppuhelper/source/servicemanager.cxx
+++ b/cppuhelper/source/servicemanager.cxx
@@ -812,13 +812,19 @@ void cppuhelper::ServiceManager::loadImplementation(
         if (ctor != nullptr) {
             assert(!implementation->info->environment.isEmpty());
             css::uno::Environment curEnv(css::uno::Environment::getCurrent());
+            if (!curEnv.is()) {
+                throw css::uno::DeploymentException(
+                    "cannot get current environment",
+                    css::uno::Reference<css::uno::XInterface>());
+            }
             css::uno::Environment env(
                 cppuhelper::detail::getEnvironment(
                     implementation->info->environment,
                     implementation->info->name));
-            if (!(curEnv.is() && env.is())) {
+            if (!env.is()) {
                 throw css::uno::DeploymentException(
-                    "cannot get environments",
+                    ("cannot get environment "
+                     + implementation->info->environment),
                     css::uno::Reference<css::uno::XInterface>());
             }
             if (curEnv.get() != env.get()) {
diff --git a/cui/source/dialogs/scriptdlg.cxx b/cui/source/dialogs/scriptdlg.cxx
index a737b9e..11ef281 100644
--- a/cui/source/dialogs/scriptdlg.cxx
+++ b/cui/source/dialogs/scriptdlg.cxx
@@ -1205,6 +1205,8 @@ void SvxScriptOrgDialog::RestorePreviousSelection()
     m_pScriptsBox->SetCurEntry( pEntry );
 }
 
+namespace {
+
 OUString ReplaceString(
     const OUString& source,
     const OUString& token,
@@ -1368,21 +1370,6 @@ OUString GetErrorMessage(
         unformatted, language, script, OUString(), OUString(), message );
 }
 
-OUString GetErrorMessage( const RuntimeException& re )
-{
-    Type t = cppu::UnoType<decltype(re)>::get();
-    OUString message = t.getTypeName() + re.Message;
-
-    return message;
-}
-
-OUString GetErrorMessage( const Exception& e )
-{
-    Type t = cppu::UnoType<decltype(e)>::get();
-    OUString message = t.getTypeName() + e.Message;
-    return message;
-}
-
 OUString GetErrorMessage( const css::uno::Any& aException )
 {
     if ( aException.getValueType() ==
@@ -1420,15 +1407,14 @@ OUString GetErrorMessage( const css::uno::Any& aException )
 
     }
     // unknown exception
+    auto msg = aException.getValueTypeName();
     Exception e;
-    RuntimeException rte;
-    if ( aException >>= rte )
+    if ( (aException >>= e) && !e.Message.isEmpty() )
     {
-        return GetErrorMessage( rte );
+        msg += ": " + e.Message;
     }
-
-    aException >>= e;
-    return GetErrorMessage( e );
+    return msg;
+}
 
 }
 


More information about the Libreoffice-commits mailing list