diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-05-24 15:47:30 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-05-25 21:46:49 +0200 |
commit | 3a51daeace695ead38cfd82b3a0f1e6f25a32e0f (patch) | |
tree | af3ef1144aef6ed62f4ab99b88d13b41bd3b3694 /desktop | |
parent | ff3bdde2527123fc9e011ff0d93e958174632186 (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 'desktop')
5 files changed, 30 insertions, 9 deletions
diff --git a/desktop/source/app/check_ext_deps.cxx b/desktop/source/app/check_ext_deps.cxx index d5b2876779f7..620377d60e62 100644 --- a/desktop/source/app/check_ext_deps.cxx +++ b/desktop/source/app/check_ext_deps.cxx @@ -37,6 +37,8 @@ #include <comphelper/processfactory.hxx> #include <comphelper/sequence.hxx> #include <cppuhelper/bootstrap.hxx> +#include <cppuhelper/exc_hlp.hxx> +#include <com/sun/star/lang/WrappedTargetRuntimeException.hpp> #include <com/sun/star/ucb/CommandAbortedException.hpp> #include <com/sun/star/ucb/CommandFailedException.hpp> #include <com/sun/star/ucb/XCommandEnvironment.hpp> @@ -256,7 +258,9 @@ static bool impl_checkDependencies( const uno::Reference< uno::XComponentContext catch ( const ucb::CommandFailedException & ) { return true; } catch ( const ucb::CommandAbortedException & ) { return true; } catch ( const lang::IllegalArgumentException & e ) { - throw uno::RuntimeException( e.Message, e.Context ); + css::uno::Any anyEx = cppu::getCaughtException(); + throw css::lang::WrappedTargetRuntimeException( e.Message, + e.Context, anyEx ); } #ifdef DEBUG diff --git a/desktop/source/deployment/gui/dp_gui_theextmgr.cxx b/desktop/source/deployment/gui/dp_gui_theextmgr.cxx index 94a8dd09df6c..fb883e15b82e 100644 --- a/desktop/source/deployment/gui/dp_gui_theextmgr.cxx +++ b/desktop/source/deployment/gui/dp_gui_theextmgr.cxx @@ -24,11 +24,13 @@ #include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/configuration/theDefaultProvider.hpp> #include <com/sun/star/deployment/DeploymentException.hpp> +#include <com/sun/star/lang/WrappedTargetRuntimeException.hpp> #include <com/sun/star/frame/Desktop.hpp> #include <com/sun/star/frame/TerminationVetoException.hpp> #include <com/sun/star/ucb/CommandAbortedException.hpp> #include <com/sun/star/ucb/CommandFailedException.hpp> #include <comphelper/propertysequence.hxx> +#include <cppuhelper/exc_hlp.hxx> #include "dp_gui_dialog2.hxx" #include "dp_gui_extensioncmdqueue.hxx" @@ -202,7 +204,9 @@ void TheExtensionManager::checkUpdates() } catch ( const ucb::CommandAbortedException & ) { return; } catch ( const lang::IllegalArgumentException & e ) { - throw uno::RuntimeException( e.Message, e.Context ); + css::uno::Any anyEx = cppu::getCaughtException(); + throw css::lang::WrappedTargetRuntimeException( e.Message, + e.Context, anyEx ); } for ( sal_Int32 i = 0; i < xAllPackages.getLength(); ++i ) @@ -281,7 +285,9 @@ void TheExtensionManager::createPackageList() } catch ( const ucb::CommandAbortedException & ) { return; } catch ( const lang::IllegalArgumentException & e ) { - throw uno::RuntimeException( e.Message, e.Context ); + css::uno::Any anyEx = cppu::getCaughtException(); + throw css::lang::WrappedTargetRuntimeException( e.Message, + e.Context, anyEx ); } for ( sal_Int32 i = 0; i < xAllPackages.getLength(); ++i ) diff --git a/desktop/source/deployment/gui/dp_gui_updatedialog.cxx b/desktop/source/deployment/gui/dp_gui_updatedialog.cxx index 1b33096de022..37513af9e031 100644 --- a/desktop/source/deployment/gui/dp_gui_updatedialog.cxx +++ b/desktop/source/deployment/gui/dp_gui_updatedialog.cxx @@ -52,6 +52,7 @@ #include <com/sun/star/frame/XDispatch.hpp> #include <com/sun/star/frame/XDispatchProvider.hpp> #include <com/sun/star/lang/IllegalArgumentException.hpp> +#include <com/sun/star/lang/WrappedTargetRuntimeException.hpp> #include <com/sun/star/lang/XMultiComponentFactory.hpp> #include <com/sun/star/lang/XSingleServiceFactory.hpp> #include <com/sun/star/task/InteractionHandler.hpp> @@ -95,6 +96,7 @@ #include <vcl/svapp.hxx> #include <comphelper/processfactory.hxx> +#include <cppuhelper/exc_hlp.hxx> #include <dp_dependencies.hxx> #include <dp_descriptioninfoset.hxx> @@ -521,7 +523,9 @@ UpdateDialog::UpdateDialog( } catch (const uno::RuntimeException &) { throw; } catch (const uno::Exception & e) { - throw uno::RuntimeException(e.Message, e.Context); + css::uno::Any anyEx = cppu::getCaughtException(); + throw css::lang::WrappedTargetRuntimeException( e.Message, + e.Context, anyEx ); } m_pUpdates->SetSelectHdl(LINK(this, UpdateDialog, selectionHandler)); m_pAll->SetToggleHdl(LINK(this, UpdateDialog, allHandler)); diff --git a/desktop/source/deployment/gui/dp_gui_updateinstalldialog.cxx b/desktop/source/deployment/gui/dp_gui_updateinstalldialog.cxx index 0541a0b04f47..4a0090456217 100644 --- a/desktop/source/deployment/gui/dp_gui_updateinstalldialog.cxx +++ b/desktop/source/deployment/gui/dp_gui_updateinstalldialog.cxx @@ -344,7 +344,9 @@ void UpdateInstallDialog::Thread::downloadExtensions() dp_misc::create_folder(nullptr, destFolder, m_updateCmdEnv.get() ); } catch (const cssu::Exception & e) { - throw cssu::Exception(e.Message + " No extensions will be installed.", nullptr); + css::uno::Any anyEx = cppu::getCaughtException(); + throw css::lang::WrappedTargetException( e.Message + " No extensions will be installed", + nullptr, anyEx ); } diff --git a/desktop/source/deployment/misc/dp_descriptioninfoset.cxx b/desktop/source/deployment/misc/dp_descriptioninfoset.cxx index 62e721e028e0..9acb846ae32e 100644 --- a/desktop/source/deployment/misc/dp_descriptioninfoset.cxx +++ b/desktop/source/deployment/misc/dp_descriptioninfoset.cxx @@ -35,6 +35,7 @@ #include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/io/SequenceInputStream.hpp> #include <com/sun/star/lang/XMultiComponentFactory.hpp> +#include <com/sun/star/lang/WrappedTargetRuntimeException.hpp> #include <com/sun/star/uno/Reference.hxx> #include <com/sun/star/uno/RuntimeException.hpp> #include <com/sun/star/uno/Sequence.hxx> @@ -93,8 +94,10 @@ OUString getNodeValue( try { return node->getNodeValue(); } catch (const css::xml::dom::DOMException & e) { - throw css::uno::RuntimeException( - "com.sun.star.xml.dom.DOMException: " + e.Message); + css::uno::Any anyEx = cppu::getCaughtException(); + throw css::lang::WrappedTargetRuntimeException( + "com.sun.star.xml.dom.DOMException: " + e.Message, + nullptr, anyEx ); } } @@ -303,8 +306,10 @@ DescriptionInfoset getDescriptionInfoset(OUString const & sExtensionFolderURL) getRootElement(); } catch (const NoDescriptionException &) { } catch (const css::deployment::DeploymentException & e) { - throw css::uno::RuntimeException( - "com.sun.star.deployment.DeploymentException: " + e.Message, nullptr); + css::uno::Any anyEx = cppu::getCaughtException(); + throw css::lang::WrappedTargetRuntimeException( + "com.sun.star.deployment.DeploymentException: " + e.Message, + nullptr, anyEx ); } return DescriptionInfoset(context, root); } |