summaryrefslogtreecommitdiff
path: root/configmgr
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2018-05-24 15:47:30 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2018-05-25 21:46:49 +0200
commit3a51daeace695ead38cfd82b3a0f1e6f25a32e0f (patch)
treeaf3ef1144aef6ed62f4ab99b88d13b41bd3b3694 /configmgr
parentff3bdde2527123fc9e011ff0d93e958174632186 (diff)
Improve re-throwing of UNO exceptions
(*) if we are already throwing a Wrapped*Exception, get the exception using cppu::getCaughtexception. (*) when catching and then immediately throwing UNO exceptions, use cppu::getCaughtException to prevent exception slicing (*) if we are going to catch an exception and then immediately throw a RuntimeException, rather throw a WrappedTargetRuntimeException and preserve the original exception information. Change-Id: Ia7a501a50ae0e6f4d05186333c8517fdcb17d558 Reviewed-on: https://gerrit.libreoffice.org/54692 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'configmgr')
-rw-r--r--configmgr/source/components.cxx8
-rw-r--r--configmgr/source/configurationregistry.cxx11
2 files changed, 13 insertions, 6 deletions
diff --git a/configmgr/source/components.cxx b/configmgr/source/components.cxx
index e296f8dfa8de..af666ba2b719 100644
--- a/configmgr/source/components.cxx
+++ b/configmgr/source/components.cxx
@@ -31,12 +31,14 @@
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/container/NoSuchElementException.hpp>
#include <com/sun/star/lang/WrappedTargetException.hpp>
+#include <com/sun/star/lang/WrappedTargetRuntimeException.hpp>
#include <com/sun/star/uno/Any.hxx>
#include <com/sun/star/uno/Exception.hpp>
#include <com/sun/star/uno/Reference.hxx>
#include <com/sun/star/uno/RuntimeException.hpp>
#include <com/sun/star/uno/XComponentContext.hpp>
#include <com/sun/star/uno/XInterface.hpp>
+#include <cppuhelper/exc_hlp.hxx>
#include <config_dconf.h>
#include <config_folders.h>
#include <osl/conditn.hxx>
@@ -453,8 +455,10 @@ css::beans::Optional< css::uno::Any > Components::getExternalValue(
throw css::uno::RuntimeException(
"unknown external value descriptor ID: " + e.Message);
} catch (css::lang::WrappedTargetException & e) {
- throw css::uno::RuntimeException(
- "cannot obtain external value: " + e.Message);
+ css::uno::Any anyEx = cppu::getCaughtException();
+ throw css::lang::WrappedTargetRuntimeException(
+ "cannot obtain external value: " + e.Message,
+ nullptr, anyEx );
}
}
return value;
diff --git a/configmgr/source/configurationregistry.cxx b/configmgr/source/configurationregistry.cxx
index 65a24c6903fa..628640c43974 100644
--- a/configmgr/source/configurationregistry.cxx
+++ b/configmgr/source/configurationregistry.cxx
@@ -29,6 +29,7 @@
#include <com/sun/star/container/XNamed.hpp>
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/lang/WrappedTargetRuntimeException.hpp>
#include <com/sun/star/registry/InvalidRegistryException.hpp>
#include <com/sun/star/registry/InvalidValueException.hpp>
#include <com/sun/star/registry/MergeConflictException.hpp>
@@ -48,6 +49,7 @@
#include <com/sun/star/uno/XInterface.hpp>
#include <com/sun/star/util/XFlushable.hpp>
#include <cppu/unotype.hxx>
+#include <cppuhelper/exc_hlp.hxx>
#include <cppuhelper/implbase.hxx>
#include <cppuhelper/supportsservice.hxx>
#include <cppuhelper/weak.hxx>
@@ -262,10 +264,11 @@ void Service::open(OUString const & rURL, sal_Bool bReadOnly, sal_Bool)
} catch (css::uno::RuntimeException &) {
throw;
} catch (css::uno::Exception & e) {
- throw css::uno::RuntimeException(
- ("com.sun.star.configuration.ConfigurationRegistry: open failed: " +
- e.Message),
- static_cast< cppu::OWeakObject * >(this));
+ css::uno::Any anyEx = cppu::getCaughtException();
+ throw css::lang::WrappedTargetRuntimeException(
+ "com.sun.star.configuration.ConfigurationRegistry: open failed: " +
+ e.Message,
+ static_cast< cppu::OWeakObject * >(this), anyEx );
}
url_ = rURL;
readOnly_ = bReadOnly;