[Libreoffice-commits] core.git: accessibility/source basctl/source chart2/source comphelper/source configmgr/source connectivity/source cppuhelper/source dbaccess/source desktop/source embeddedobj/source eventattacher/source extensions/source forms/source framework/source jvmaccess/Library_jvmaccess.mk jvmaccess/source oox/source package/source pyuno/source reportdesign/source sax/source scripting/source sc/source sd/source sfx2/source sot/source stoc/source svl/source svx/source sw/source ucb/source unoxml/source uui/source vbahelper/source writerfilter/source xmloff/source xmlscript/source

Noel Grandin noel.grandin at collabora.co.uk
Fri May 25 19:47:13 UTC 2018


 accessibility/source/extended/textwindowaccessibility.cxx         |    7 
 basctl/source/dlged/dlgedobj.cxx                                  |    6 
 chart2/source/controller/sidebar/Chart2PanelFactory.cxx           |    6 
 chart2/source/tools/WrappedPropertySet.cxx                        |   10 
 comphelper/source/eventattachermgr/eventattachermgr.cxx           |    4 
 comphelper/source/misc/backupfilehelper.cxx                       |    6 
 comphelper/source/misc/storagehelper.cxx                          |   16 +
 configmgr/source/components.cxx                                   |    8 
 configmgr/source/configurationregistry.cxx                        |   11 -
 connectivity/source/drivers/dbase/DTables.cxx                     |    6 
 connectivity/source/drivers/hsqldb/HConnection.cxx                |    3 
 connectivity/source/drivers/jdbc/JConnection.cxx                  |    7 
 connectivity/source/drivers/jdbc/Object.cxx                       |    5 
 connectivity/source/drivers/postgresql/pq_xcolumns.cxx            |    6 
 connectivity/source/drivers/postgresql/pq_xindexcolumns.cxx       |    6 
 connectivity/source/drivers/postgresql/pq_xindexes.cxx            |    6 
 connectivity/source/drivers/postgresql/pq_xkeycolumns.cxx         |    6 
 connectivity/source/drivers/postgresql/pq_xkeys.cxx               |    6 
 connectivity/source/drivers/postgresql/pq_xtables.cxx             |    6 
 connectivity/source/drivers/postgresql/pq_xusers.cxx              |    6 
 connectivity/source/drivers/postgresql/pq_xviews.cxx              |    6 
 connectivity/source/sdbcx/VCollection.cxx                         |    4 
 cppuhelper/source/component.cxx                                   |    8 
 cppuhelper/source/implbase.cxx                                    |   14 -
 cppuhelper/source/propertysetmixin.cxx                            |  106 +++++-----
 dbaccess/source/core/api/CRowSetDataColumn.cxx                    |    3 
 dbaccess/source/core/dataaccess/databasedocument.cxx              |   21 +
 dbaccess/source/core/dataaccess/definitioncontainer.cxx           |    8 
 dbaccess/source/filter/xml/xmlfilter.cxx                          |    6 
 dbaccess/source/ui/control/tabletree.cxx                          |    5 
 dbaccess/source/ui/dlg/DbAdminImpl.cxx                            |    6 
 desktop/source/app/check_ext_deps.cxx                             |    6 
 desktop/source/deployment/gui/dp_gui_theextmgr.cxx                |   10 
 desktop/source/deployment/gui/dp_gui_updatedialog.cxx             |    6 
 desktop/source/deployment/gui/dp_gui_updateinstalldialog.cxx      |    4 
 desktop/source/deployment/misc/dp_descriptioninfoset.cxx          |   13 -
 embeddedobj/source/commonembedding/embedobj.cxx                   |    6 
 embeddedobj/source/commonembedding/persistence.cxx                |    5 
 embeddedobj/source/msole/oleembed.cxx                             |   14 -
 eventattacher/source/eventattacher.cxx                            |    6 
 extensions/source/ole/oleobjw.cxx                                 |   64 +++---
 extensions/source/update/feed/updatefeed.cxx                      |   29 +-
 forms/source/component/clickableimage.cxx                         |    6 
 forms/source/xforms/submission.cxx                                |    6 
 framework/source/accelerators/storageholder.cxx                   |   17 +
 framework/source/fwe/xml/menuconfiguration.cxx                    |   21 +
 framework/source/uiconfiguration/moduleuiconfigurationmanager.cxx |    7 
 jvmaccess/Library_jvmaccess.mk                                    |    1 
 jvmaccess/source/classpath.cxx                                    |    8 
 oox/source/docprop/docprophandler.cxx                             |    6 
 package/source/manifest/ManifestWriter.cxx                        |    6 
 package/source/xstor/ohierarchyholder.cxx                         |   12 -
 package/source/zippackage/ZipPackage.cxx                          |   30 +-
 package/source/zippackage/zipfileaccess.cxx                       |    7 
 pyuno/source/module/pyuno_adapter.cxx                             |    4 
 pyuno/source/module/pyuno_runtime.cxx                             |    4 
 reportdesign/source/core/api/ReportDefinition.cxx                 |    5 
 sax/source/expatwrap/saxwriter.cxx                                |   15 -
 sc/source/ui/sidebar/ScPanelFactory.cxx                           |    6 
 sc/source/ui/unoobj/dapiuno.cxx                                   |    7 
 sc/source/ui/vba/vbaaxes.cxx                                      |    6 
 sc/source/ui/vba/vbachartobjects.cxx                              |    5 
 sc/source/ui/vba/vbarange.cxx                                     |   10 
 scripting/source/protocolhandler/scripthandler.cxx                |   12 -
 scripting/source/provider/ActiveMSPList.cxx                       |    3 
 scripting/source/provider/ProviderCache.cxx                       |   15 -
 sd/source/core/stlsheet.cxx                                       |    7 
 sfx2/source/doc/DocumentMetadataAccess.cxx                        |   86 ++++----
 sfx2/source/doc/SfxDocumentMetaData.cxx                           |   36 +--
 sfx2/source/doc/sfxbasemodel.cxx                                  |   20 +
 sfx2/source/view/ipclient.cxx                                     |    8 
 sot/source/unoolestorage/xolesimplestorage.cxx                    |   12 -
 stoc/source/implementationregistration/implreg.cxx                |    8 
 stoc/source/invocation/invocation.cxx                             |    4 
 stoc/source/javaloader/javaloader.cxx                             |    7 
 stoc/source/javavm/javavm.cxx                                     |   30 +-
 stoc/source/uriproc/UriReferenceFactory.cxx                       |    6 
 svl/source/fsstor/fsstorage.cxx                                   |    6 
 svx/source/svdraw/svdoole2.cxx                                    |    7 
 svx/source/unodraw/unoshap4.cxx                                   |   23 +-
 svx/source/xml/xmleohlp.cxx                                       |    6 
 sw/source/core/unocore/unoparagraph.cxx                           |   12 -
 sw/source/core/unocore/unoport.cxx                                |    8 
 sw/source/core/unocore/unorefmk.cxx                               |    8 
 sw/source/core/unocore/unosect.cxx                                |   12 -
 sw/source/core/unocore/unostyle.cxx                               |   24 +-
 sw/source/core/unocore/unotext.cxx                                |   11 -
 sw/source/uibase/uno/unoatxt.cxx                                  |    6 
 ucb/source/cacher/cachedcontentresultset.cxx                      |   21 +
 ucb/source/core/FileAccess.cxx                                    |    7 
 ucb/source/ucp/ftp/ftpcontentprovider.cxx                         |    7 
 ucb/source/ucp/package/pkgprovider.cxx                            |    4 
 ucb/source/ucp/tdoc/tdoc_storage.cxx                              |   11 -
 unoxml/source/rdf/librdf_repository.cxx                           |   42 ++-
 uui/source/interactionhandler.cxx                                 |   10 
 uui/source/requeststringresolver.cxx                              |    6 
 vbahelper/source/msforms/vbacontrols.cxx                          |    6 
 writerfilter/source/filter/RtfFilter.cxx                          |    6 
 writerfilter/source/filter/WriterFilter.cxx                       |    7 
 writerfilter/source/ooxml/OOXMLDocumentImpl.cxx                   |    9 
 xmloff/source/meta/xmlmetai.cxx                                   |   11 -
 xmlscript/source/xmldlg_imexp/xmldlg_impmodels.cxx                |    6 
 102 files changed, 793 insertions(+), 413 deletions(-)

New commits:
commit 3a51daeace695ead38cfd82b3a0f1e6f25a32e0f
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Thu May 24 15:47:30 2018 +0200

    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 at libreoffice.org>
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/accessibility/source/extended/textwindowaccessibility.cxx b/accessibility/source/extended/textwindowaccessibility.cxx
index 50ea92f78238..91055abc841b 100644
--- a/accessibility/source/extended/textwindowaccessibility.cxx
+++ b/accessibility/source/extended/textwindowaccessibility.cxx
@@ -20,6 +20,8 @@
 #include <sal/config.h>
 
 #include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
+#include <com/sun/star/lang/WrappedTargetRuntimeException.hpp>
+#include <cppuhelper/exc_hlp.hxx>
 #include <extended/textwindowaccessibility.hxx>
 #include <comphelper/accessibleeventnotifier.hxx>
 #include <unotools/accessiblerelationsethelper.hxx>
@@ -538,10 +540,11 @@ css::accessibility::TextSegment SAL_CALL Paragraph::getTextAtLineWithCaret(  )
             getTextAtLineNumber( nLineNo ) :
             css::accessibility::TextSegment();
     } catch (const css::lang::IndexOutOfBoundsException&) {
-        throw css::uno::RuntimeException(
+        css::uno::Any anyEx = cppu::getCaughtException();
+        throw css::lang::WrappedTargetRuntimeException(
             "textwindowaccessibility.cxx:"
             " Paragraph::getTextAtLineWithCaret",
-            static_cast< css::uno::XWeak * >( this ) );
+            static_cast< css::uno::XWeak * >( this ), anyEx );
     }
 }
 
diff --git a/basctl/source/dlged/dlgedobj.cxx b/basctl/source/dlged/dlgedobj.cxx
index 8052f3cb159a..968a2ed3ed81 100644
--- a/basctl/source/dlged/dlgedobj.cxx
+++ b/basctl/source/dlged/dlgedobj.cxx
@@ -41,6 +41,7 @@
 #include <com/sun/star/lang/WrappedTargetRuntimeException.hpp>
 #include <com/sun/star/script/XScriptEventsSupplier.hpp>
 #include <com/sun/star/table/CellAddress.hpp>
+#include <cppuhelper/exc_hlp.hxx>
 #include <o3tl/functional.hxx>
 #include <unotools/sharedunocomponent.hxx>
 #include <vcl/svapp.hxx>
@@ -1136,10 +1137,11 @@ void DlgEdObj::_propertyChange( const  css::beans::PropertyChangeEvent& evt )
                 {
                     NameChange(evt);
                 }
-                catch (container::NoSuchElementException const& e)
+                catch (container::NoSuchElementException const&)
                 {
+                    css::uno::Any anyEx = cppu::getCaughtException();
                     throw lang::WrappedTargetRuntimeException("", nullptr,
-                            uno::Any(e));
+                            anyEx);
                 }
             }
         }
diff --git a/chart2/source/controller/sidebar/Chart2PanelFactory.cxx b/chart2/source/controller/sidebar/Chart2PanelFactory.cxx
index 4034156f289d..19ce79f8fad7 100644
--- a/chart2/source/controller/sidebar/Chart2PanelFactory.cxx
+++ b/chart2/source/controller/sidebar/Chart2PanelFactory.cxx
@@ -26,6 +26,7 @@
 #include <rtl/ref.hxx>
 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
 #include <com/sun/star/lang/WrappedTargetRuntimeException.hpp>
+#include <cppuhelper/exc_hlp.hxx>
 #include <comphelper/namedvaluecollection.hxx>
 #include <cppuhelper/supportsservice.hxx>
 
@@ -109,11 +110,12 @@ Reference<css::ui::XUIElement> SAL_CALL ChartPanelFactory::createUIElement (
     {
         throw;
     }
-    catch (const css::uno::Exception& e)
+    catch (const css::uno::Exception&)
     {
+        css::uno::Any anyEx = cppu::getCaughtException();
         throw css::lang::WrappedTargetRuntimeException(
             "ChartPanelFactory::createUIElement exception",
-            nullptr, css::uno::Any(e));
+            nullptr, anyEx );
     }
 
     return xElement;
diff --git a/chart2/source/tools/WrappedPropertySet.cxx b/chart2/source/tools/WrappedPropertySet.cxx
index b63d25dfeea7..72c296ea6185 100644
--- a/chart2/source/tools/WrappedPropertySet.cxx
+++ b/chart2/source/tools/WrappedPropertySet.cxx
@@ -127,10 +127,9 @@ void SAL_CALL WrappedPropertySet::setPropertyValue( const OUString& rPropertyNam
     }
     catch( const uno::Exception& ex )
     {
+        css::uno::Any anyEx = cppu::getCaughtException();
         OSL_FAIL("invalid exception caught in WrappedPropertySet::setPropertyValue");
-        lang::WrappedTargetException aWrappedException;
-        aWrappedException.TargetException <<= ex;
-        throw aWrappedException;
+        throw lang::WrappedTargetException( ex.Message, nullptr, anyEx );
     }
 }
 Any SAL_CALL WrappedPropertySet::getPropertyValue( const OUString& rPropertyName )
@@ -165,10 +164,9 @@ Any SAL_CALL WrappedPropertySet::getPropertyValue( const OUString& rPropertyName
     }
     catch( const uno::Exception& ex )
     {
+        css::uno::Any anyEx = cppu::getCaughtException();
         OSL_FAIL("invalid exception caught in WrappedPropertySet::setPropertyValue");
-        lang::WrappedTargetException aWrappedException;
-        aWrappedException.TargetException <<= ex;
-        throw aWrappedException;
+        throw lang::WrappedTargetException( ex.Message, nullptr, anyEx );
     }
 
     return aRet;
diff --git a/comphelper/source/eventattachermgr/eventattachermgr.cxx b/comphelper/source/eventattachermgr/eventattachermgr.cxx
index 7da8ec29200f..4e5cdb0e0e53 100644
--- a/comphelper/source/eventattachermgr/eventattachermgr.cxx
+++ b/comphelper/source/eventattachermgr/eventattachermgr.cxx
@@ -43,6 +43,7 @@
 #include <com/sun/star/script/XScriptListener.hpp>
 #include <cppuhelper/weak.hxx>
 #include <comphelper/interfacecontainer2.hxx>
+#include <cppuhelper/exc_hlp.hxx>
 #include <cppuhelper/implbase.hxx>
 #include <rtl/ref.hxx>
 
@@ -311,9 +312,10 @@ Any SAL_CALL AttacherAllListener_Impl::approveFiring( const AllEventObject& Even
                 }
                 catch (const CannotConvertException& e)
                 {
+                    css::uno::Any anyEx = cppu::getCaughtException();
                     throw css::lang::WrappedTargetRuntimeException(
                         "wrapped CannotConvertException " + e.Message,
-                        css::uno::Reference<css::uno::XInterface>(), Any(e));
+                        css::uno::Reference<css::uno::XInterface>(), anyEx);
                 }
             }
         }
diff --git a/comphelper/source/misc/backupfilehelper.cxx b/comphelper/source/misc/backupfilehelper.cxx
index 3c681437eb55..530827c6f31b 100644
--- a/comphelper/source/misc/backupfilehelper.cxx
+++ b/comphelper/source/misc/backupfilehelper.cxx
@@ -19,6 +19,7 @@
 #include <zlib.h>
 
 #include <comphelper/processfactory.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/uno/Sequence.hxx>
@@ -38,6 +39,7 @@
 #include <com/sun/star/io/XOutputStream.hpp>
 #include <com/sun/star/xml/sax/XDocumentHandler.hpp>
 #include <com/sun/star/beans/XPropertySet.hpp>
+#include <cppuhelper/exc_hlp.hxx>
 
 using namespace css;
 using namespace css::xml::dom;
@@ -595,7 +597,9 @@ namespace
             }
             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/comphelper/source/misc/storagehelper.cxx b/comphelper/source/misc/storagehelper.cxx
index abd06ed048a9..f1e87937b8d2 100644
--- a/comphelper/source/misc/storagehelper.cxx
+++ b/comphelper/source/misc/storagehelper.cxx
@@ -28,6 +28,7 @@
 #include <com/sun/star/embed/FileSystemStorageFactory.hpp>
 #include <com/sun/star/io/IOException.hpp>
 #include <com/sun/star/lang/XSingleServiceFactory.hpp>
+#include <com/sun/star/lang/WrappedTargetRuntimeException.hpp>
 #include <com/sun/star/ucb/SimpleFileAccess.hpp>
 #include <com/sun/star/beans/XPropertySet.hpp>
 #include <com/sun/star/beans/PropertyValue.hpp>
@@ -55,6 +56,7 @@
 #include <comphelper/documentconstants.hxx>
 #include <comphelper/storagehelper.hxx>
 #include <comphelper/sequence.hxx>
+#include <cppuhelper/exc_hlp.hxx>
 
 #if HAVE_FEATURE_GPGME
 # include <gpgme.h>
@@ -119,6 +121,7 @@ uno::Reference< embed::XStorage > OStorageHelper::GetStorageFromURL2(
     aArgs[1] <<= nStorageMode;
 
     uno::Reference< lang::XSingleServiceFactory > xFact;
+    css::uno::Any anyEx;
     try {
         ::ucbhelper::Content aCntnt( aURL,
             uno::Reference< css::ucb::XCommandEnvironment > (),
@@ -128,9 +131,18 @@ uno::Reference< embed::XStorage > OStorageHelper::GetStorageFromURL2(
         } else {
             xFact = GetFileSystemStorageFactory( rxContext );
         }
-    } catch (uno::Exception &) { }
+    } catch (uno::Exception &)
+    {
+        anyEx = cppu::getCaughtException();
+    }
 
-    if (!xFact.is()) throw uno::RuntimeException();
+    if (!xFact.is())
+    {
+        if (anyEx.hasValue())
+            throw css::lang::WrappedTargetRuntimeException( "", nullptr, anyEx );
+        else
+            throw uno::RuntimeException();
+    }
 
     uno::Reference< embed::XStorage > xTempStorage(
         xFact->createInstanceWithArguments( aArgs ), uno::UNO_QUERY_THROW );
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;
diff --git a/connectivity/source/drivers/dbase/DTables.cxx b/connectivity/source/drivers/dbase/DTables.cxx
index 90f62bdc526f..056b287aa994 100644
--- a/connectivity/source/drivers/dbase/DTables.cxx
+++ b/connectivity/source/drivers/dbase/DTables.cxx
@@ -32,6 +32,7 @@
 #include <com/sun/star/lang/XUnoTunnel.hpp>
 #include <dbase/DCatalog.hxx>
 #include <comphelper/types.hxx>
+#include <cppuhelper/exc_hlp.hxx>
 #include <strings.hrc>
 #include <connectivity/dbexception.hxx>
 
@@ -85,9 +86,10 @@ sdbcx::ObjectType ODbaseTables::appendObject( const OUString& _rForName, const R
             {
                 throw;
             }
-            catch(Exception&)
+            catch(Exception& ex)
             {
-                throw SQLException();
+                css::uno::Any anyEx = cppu::getCaughtException();
+                throw SQLException( ex.Message, nullptr, "", 0, anyEx );
             }
         }
     }
diff --git a/connectivity/source/drivers/hsqldb/HConnection.cxx b/connectivity/source/drivers/hsqldb/HConnection.cxx
index cf4cafbe347c..7da46daafb2f 100644
--- a/connectivity/source/drivers/hsqldb/HConnection.cxx
+++ b/connectivity/source/drivers/hsqldb/HConnection.cxx
@@ -231,9 +231,10 @@ namespace connectivity { namespace hsqldb
         catch( const RuntimeException& ) { throw; }
         catch( const Exception& )
         {
+            css::uno::Any anyEx = cppu::getCaughtException();
             ::connectivity::SharedResources aResources;
             const OUString sError( aResources.getResourceString(STR_NO_TABLE_CONTAINER));
-            throw WrappedTargetException( sError ,*this, ::cppu::getCaughtException() );
+            throw WrappedTargetException( sError ,*this, anyEx );
         }
 
         SAL_WARN_IF( !xTables.is(), "connectivity.hsqldb", "OHsqlConnection::impl_getTableContainer_throw: post condition not met!" );
diff --git a/connectivity/source/drivers/jdbc/JConnection.cxx b/connectivity/source/drivers/jdbc/JConnection.cxx
index 5fdc586cc038..bfaef457d35e 100644
--- a/connectivity/source/drivers/jdbc/JConnection.cxx
+++ b/connectivity/source/drivers/jdbc/JConnection.cxx
@@ -39,6 +39,7 @@
 #include <com/sun/star/uno/XComponentContext.hpp>
 #include <jvmaccess/classpath.hxx>
 #include <comphelper/namedvaluecollection.hxx>
+#include <cppuhelper/exc_hlp.hxx>
 #include <rtl/ustrbuf.hxx>
 #include <jni.h>
 #include <strings.hrc>
@@ -688,15 +689,15 @@ void java_sql_Connection::loadDriverFromProperties( const OUString& _sDriverClas
             }
         }
     }
-    catch( const SQLException& e )
+    catch( const SQLException& )
     {
+        css::uno::Any anyEx = cppu::getCaughtException();
         throw SQLException(
             lcl_getDriverLoadErrorMessage( getResources(),_sDriverClass, _sDriverClassPath ),
             *this,
             OUString(),
             1000,
-            makeAny(e)
-        );
+            anyEx);
     }
     catch( Exception& )
     {
diff --git a/connectivity/source/drivers/jdbc/Object.cxx b/connectivity/source/drivers/jdbc/Object.cxx
index 20edd90d6192..4a9a854d48f7 100644
--- a/connectivity/source/drivers/jdbc/Object.cxx
+++ b/connectivity/source/drivers/jdbc/Object.cxx
@@ -28,6 +28,7 @@
 #include <strings.hxx>
 
 #include <comphelper/logging.hxx>
+#include <cppuhelper/exc_hlp.hxx>
 
 #include <memory>
 
@@ -222,7 +223,9 @@ void java_lang_Object::ThrowRuntimeException( JNIEnv* _pEnvironment, const Refer
     }
     catch (const SQLException& e)
     {
-        throw WrappedTargetRuntimeException(e.Message, e.Context, makeAny(e));
+        css::uno::Any anyEx = cppu::getCaughtException();
+        throw css::lang::WrappedTargetRuntimeException( e.Message,
+                        e.Context, anyEx );
     }
 }
 
diff --git a/connectivity/source/drivers/postgresql/pq_xcolumns.cxx b/connectivity/source/drivers/postgresql/pq_xcolumns.cxx
index 707d634044ce..180ded29a0b8 100644
--- a/connectivity/source/drivers/postgresql/pq_xcolumns.cxx
+++ b/connectivity/source/drivers/postgresql/pq_xcolumns.cxx
@@ -37,11 +37,13 @@
 #include <rtl/ustrbuf.hxx>
 #include <rtl/strbuf.hxx>
 #include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
+#include <com/sun/star/lang/WrappedTargetRuntimeException.hpp>
 #include <com/sun/star/sdbc/SQLException.hpp>
 #include <com/sun/star/sdbc/XRow.hpp>
 #include <com/sun/star/sdbc/DataType.hpp>
 #include <com/sun/star/sdbc/ColumnValue.hpp>
 
+#include <cppuhelper/exc_hlp.hxx>
 #include <cppuhelper/implbase.hxx>
 
 #include "pq_xcolumns.hxx"
@@ -331,7 +333,9 @@ void Columns::refresh()
     }
     catch ( css::sdbc::SQLException & e )
     {
-        throw RuntimeException( e.Message , e.Context );
+        css::uno::Any anyEx = cppu::getCaughtException();
+        throw css::lang::WrappedTargetRuntimeException( e.Message,
+                        nullptr, anyEx );
     }
     fire( RefreshedBroadcaster( *this ) );
 }
diff --git a/connectivity/source/drivers/postgresql/pq_xindexcolumns.cxx b/connectivity/source/drivers/postgresql/pq_xindexcolumns.cxx
index bab35147b26b..8501d84bea36 100644
--- a/connectivity/source/drivers/postgresql/pq_xindexcolumns.cxx
+++ b/connectivity/source/drivers/postgresql/pq_xindexcolumns.cxx
@@ -38,10 +38,12 @@
 
 #include <rtl/ustrbuf.hxx>
 #include <rtl/strbuf.hxx>
+#include <com/sun/star/lang/WrappedTargetRuntimeException.hpp>
 #include <com/sun/star/sdbc/SQLException.hpp>
 #include <com/sun/star/sdbc/XRow.hpp>
 #include <com/sun/star/sdbc/DataType.hpp>
 #include <com/sun/star/sdbc/ColumnValue.hpp>
+#include <cppuhelper/exc_hlp.hxx>
 
 #include "pq_xcolumns.hxx"
 #include "pq_xindexcolumns.hxx"
@@ -147,7 +149,9 @@ void IndexColumns::refresh()
     }
     catch ( css::sdbc::SQLException & e )
     {
-        throw RuntimeException( e.Message , e.Context );
+        css::uno::Any anyEx = cppu::getCaughtException();
+        throw css::lang::WrappedTargetRuntimeException( e.Message,
+                        e.Context, anyEx );
     }
 
     fire( RefreshedBroadcaster( *this ) );
diff --git a/connectivity/source/drivers/postgresql/pq_xindexes.cxx b/connectivity/source/drivers/postgresql/pq_xindexes.cxx
index 22b8acf7102c..70f35d515cc2 100644
--- a/connectivity/source/drivers/postgresql/pq_xindexes.cxx
+++ b/connectivity/source/drivers/postgresql/pq_xindexes.cxx
@@ -37,11 +37,13 @@
 #include <rtl/ustrbuf.hxx>
 #include <rtl/strbuf.hxx>
 #include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
+#include <com/sun/star/lang/WrappedTargetRuntimeException.hpp>
 #include <com/sun/star/sdbc/SQLException.hpp>
 #include <com/sun/star/sdbc/XRow.hpp>
 #include <com/sun/star/sdbc/XParameters.hpp>
 #include <com/sun/star/sdbc/KeyRule.hpp>
 #include <com/sun/star/sdbcx/KeyType.hpp>
+#include <cppuhelper/exc_hlp.hxx>
 
 #include "pq_xindexes.hxx"
 #include "pq_xindex.hxx"
@@ -180,7 +182,9 @@ void Indexes::refresh()
     }
     catch ( css::sdbc::SQLException & e )
     {
-        throw RuntimeException( e.Message , e.Context );
+        css::uno::Any anyEx = cppu::getCaughtException();
+        throw css::lang::WrappedTargetRuntimeException( e.Message,
+                        e.Context, anyEx );
     }
 
     fire( RefreshedBroadcaster( *this ) );
diff --git a/connectivity/source/drivers/postgresql/pq_xkeycolumns.cxx b/connectivity/source/drivers/postgresql/pq_xkeycolumns.cxx
index 782861615707..1982d348851c 100644
--- a/connectivity/source/drivers/postgresql/pq_xkeycolumns.cxx
+++ b/connectivity/source/drivers/postgresql/pq_xkeycolumns.cxx
@@ -36,10 +36,12 @@
 
 #include <rtl/ustrbuf.hxx>
 #include <rtl/strbuf.hxx>
+#include <com/sun/star/lang/WrappedTargetRuntimeException.hpp>
 #include <com/sun/star/sdbc/SQLException.hpp>
 #include <com/sun/star/sdbc/XRow.hpp>
 #include <com/sun/star/sdbc/DataType.hpp>
 #include <com/sun/star/sdbc/ColumnValue.hpp>
+#include <cppuhelper/exc_hlp.hxx>
 
 #include "pq_xcolumns.hxx"
 #include "pq_xkeycolumns.hxx"
@@ -149,7 +151,9 @@ void KeyColumns::refresh()
     }
     catch ( css::sdbc::SQLException & e )
     {
-        throw RuntimeException( e.Message , e.Context );
+        css::uno::Any anyEx = cppu::getCaughtException();
+        throw css::lang::WrappedTargetRuntimeException( e.Message,
+                        e.Context, anyEx );
     }
 
     fire( RefreshedBroadcaster( *this ) );
diff --git a/connectivity/source/drivers/postgresql/pq_xkeys.cxx b/connectivity/source/drivers/postgresql/pq_xkeys.cxx
index 07ee93726a4d..09aa41ea0f15 100644
--- a/connectivity/source/drivers/postgresql/pq_xkeys.cxx
+++ b/connectivity/source/drivers/postgresql/pq_xkeys.cxx
@@ -37,11 +37,13 @@
 #include <rtl/ustrbuf.hxx>
 #include <rtl/strbuf.hxx>
 #include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
+#include <com/sun/star/lang/WrappedTargetRuntimeException.hpp>
 #include <com/sun/star/sdbc/SQLException.hpp>
 #include <com/sun/star/sdbc/XRow.hpp>
 #include <com/sun/star/sdbc/XParameters.hpp>
 #include <com/sun/star/sdbc/KeyRule.hpp>
 #include <com/sun/star/sdbcx/KeyType.hpp>
+#include <cppuhelper/exc_hlp.hxx>
 
 #include "pq_xkeys.hxx"
 #include "pq_xkey.hxx"
@@ -198,7 +200,9 @@ void Keys::refresh()
     }
     catch ( css::sdbc::SQLException & e )
     {
-        throw RuntimeException( e.Message , e.Context );
+        css::uno::Any anyEx = cppu::getCaughtException();
+        throw css::lang::WrappedTargetRuntimeException( e.Message,
+                        e.Context, anyEx );
     }
 
     fire( RefreshedBroadcaster( *this ) );
diff --git a/connectivity/source/drivers/postgresql/pq_xtables.cxx b/connectivity/source/drivers/postgresql/pq_xtables.cxx
index 0eb86f12942c..907e777f273d 100644
--- a/connectivity/source/drivers/postgresql/pq_xtables.cxx
+++ b/connectivity/source/drivers/postgresql/pq_xtables.cxx
@@ -36,12 +36,14 @@
 
 #include <rtl/ustrbuf.hxx>
 #include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
+#include <com/sun/star/lang/WrappedTargetRuntimeException.hpp>
 #include <com/sun/star/sdbc/SQLException.hpp>
 #include <com/sun/star/sdbc/XRow.hpp>
 #include <com/sun/star/sdbcx/Privilege.hpp>
 #include <com/sun/star/sdbcx/KeyType.hpp>
 #include <com/sun/star/sdbc/KeyRule.hpp>
 #include <com/sun/star/sdbc/DataType.hpp>
+#include <cppuhelper/exc_hlp.hxx>
 
 #include "pq_xtables.hxx"
 #include "pq_xviews.hxx"
@@ -142,7 +144,9 @@ void Tables::refresh()
     }
     catch ( const css::sdbc::SQLException & e )
     {
-        throw RuntimeException( e.Message , e.Context );
+        css::uno::Any anyEx = cppu::getCaughtException();
+        throw css::lang::WrappedTargetRuntimeException( e.Message,
+                        e.Context, anyEx );
     }
 
     fire( RefreshedBroadcaster( *this ) );
diff --git a/connectivity/source/drivers/postgresql/pq_xusers.cxx b/connectivity/source/drivers/postgresql/pq_xusers.cxx
index e7d6b6112b5a..cb30c0b50b4c 100644
--- a/connectivity/source/drivers/postgresql/pq_xusers.cxx
+++ b/connectivity/source/drivers/postgresql/pq_xusers.cxx
@@ -36,9 +36,11 @@
 
 #include <rtl/ustrbuf.hxx>
 #include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
+#include <com/sun/star/lang/WrappedTargetRuntimeException.hpp>
 #include <com/sun/star/sdbc/SQLException.hpp>
 #include <com/sun/star/sdbc/XRow.hpp>
 #include <com/sun/star/sdbcx/Privilege.hpp>
+#include <cppuhelper/exc_hlp.hxx>
 
 #include "pq_xusers.hxx"
 #include "pq_xuser.hxx"
@@ -109,7 +111,9 @@ void Users::refresh()
     }
     catch ( css::sdbc::SQLException & e )
     {
-        throw RuntimeException( e.Message , e.Context );
+        css::uno::Any anyEx = cppu::getCaughtException();
+        throw css::lang::WrappedTargetRuntimeException( e.Message,
+                        e.Context, anyEx );
     }
 
     fire( RefreshedBroadcaster( *this ) );
diff --git a/connectivity/source/drivers/postgresql/pq_xviews.cxx b/connectivity/source/drivers/postgresql/pq_xviews.cxx
index 7b1abf581468..8f1d58d07f8e 100644
--- a/connectivity/source/drivers/postgresql/pq_xviews.cxx
+++ b/connectivity/source/drivers/postgresql/pq_xviews.cxx
@@ -36,8 +36,10 @@
 
 #include <rtl/ustrbuf.hxx>
 #include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
+#include <com/sun/star/lang/WrappedTargetRuntimeException.hpp>
 #include <com/sun/star/sdbc/SQLException.hpp>
 #include <com/sun/star/sdbc/XRow.hpp>
+#include <cppuhelper/exc_hlp.hxx>
 
 #include "pq_xviews.hxx"
 #include "pq_xview.hxx"
@@ -124,7 +126,9 @@ void Views::refresh()
     }
     catch ( css::sdbc::SQLException & e )
     {
-        throw RuntimeException( e.Message , e.Context );
+        css::uno::Any anyEx = cppu::getCaughtException();
+        throw css::lang::WrappedTargetRuntimeException( e.Message,
+                        e.Context, anyEx );
     }
     fire( RefreshedBroadcaster( *this ) );
 }
diff --git a/connectivity/source/sdbcx/VCollection.cxx b/connectivity/source/sdbcx/VCollection.cxx
index 595b66576ed1..70f15dc4bd9d 100644
--- a/connectivity/source/sdbcx/VCollection.cxx
+++ b/connectivity/source/sdbcx/VCollection.cxx
@@ -27,6 +27,7 @@
 #include <comphelper/enumhelper.hxx>
 #include <comphelper/types.hxx>
 #include <comphelper/property.hxx>
+#include <cppuhelper/exc_hlp.hxx>
 #include <TConnection.hxx>
 #include <rtl/ustrbuf.hxx>
 #include <strings.hrc>
@@ -533,6 +534,7 @@ ObjectType OCollection::getObject(sal_Int32 _nIndex)
         }
         catch(const SQLException& e)
         {
+            css::uno::Any anyEx = cppu::getCaughtException();
             try
             {
                 dropImpl(_nIndex,false);
@@ -540,7 +542,7 @@ ObjectType OCollection::getObject(sal_Int32 _nIndex)
             catch(const Exception& )
             {
             }
-            throw WrappedTargetException(e.Message,static_cast<XTypeProvider*>(this),makeAny(e));
+            throw WrappedTargetException(e.Message,static_cast<XTypeProvider*>(this),anyEx);
         }
         m_pElements->setObject(_nIndex,xName);
     }
diff --git a/cppuhelper/source/component.cxx b/cppuhelper/source/component.cxx
index d906243bfddb..16cf56f257e6 100644
--- a/cppuhelper/source/component.cxx
+++ b/cppuhelper/source/component.cxx
@@ -20,8 +20,10 @@
 #include <rtl/string.hxx>
 #include <osl/diagnose.h>
 #include <cppuhelper/component.hxx>
+#include <cppuhelper/exc_hlp.hxx>
 #include <cppuhelper/queryinterface.hxx>
 #include <cppuhelper/typeprovider.hxx>
+#include <com/sun/star/lang/WrappedTargetRuntimeException.hpp>
 #include <com/sun/star/uno/RuntimeException.hpp>
 
 using namespace osl;
@@ -189,8 +191,10 @@ void OComponentHelper::dispose()
         }
         catch (Exception & exc)
         {
-            throw RuntimeException(
-                "unexpected UNO exception caught: " + exc.Message );
+            css::uno::Any anyEx = cppu::getCaughtException();
+            throw lang::WrappedTargetRuntimeException(
+                "unexpected UNO exception caught: " + exc.Message,
+                nullptr, anyEx );
         }
     }
     else
diff --git a/cppuhelper/source/implbase.cxx b/cppuhelper/source/implbase.cxx
index b8bc91b769b1..f16c587431f0 100644
--- a/cppuhelper/source/implbase.cxx
+++ b/cppuhelper/source/implbase.cxx
@@ -18,11 +18,13 @@
  */
 
 #include <cppuhelper/compbase_ex.hxx>
+#include <cppuhelper/exc_hlp.hxx>
 #include <osl/diagnose.h>
 #include <rtl/instance.hxx>
 #include <rtl/string.hxx>
 
 #include <com/sun/star/lang/XComponent.hpp>
+#include <com/sun/star/lang/WrappedTargetRuntimeException.hpp>
 #include <com/sun/star/uno/RuntimeException.hpp>
 
 using namespace ::osl;
@@ -120,8 +122,10 @@ void WeakComponentImplHelperBase::dispose()
         }
         catch (Exception & exc)
         {
-            throw RuntimeException(
-                "unexpected UNO exception caught: " + exc.Message );
+            css::uno::Any anyEx = cppu::getCaughtException();
+            throw lang::WrappedTargetRuntimeException(
+                "unexpected UNO exception caught: " + exc.Message,
+                nullptr, anyEx );
         }
     }
 }
@@ -244,8 +248,10 @@ void WeakAggComponentImplHelperBase::dispose()
         }
         catch (Exception & exc)
         {
-            throw RuntimeException(
-                "unexpected UNO exception caught: " + exc.Message );
+            css::uno::Any anyEx = cppu::getCaughtException();
+            throw lang::WrappedTargetRuntimeException(
+                "unexpected UNO exception caught: " + exc.Message,
+                nullptr, anyEx );
         }
     }
 }
diff --git a/cppuhelper/source/propertysetmixin.cxx b/cppuhelper/source/propertysetmixin.cxx
index 8469f1a7c51d..88e104d90453 100644
--- a/cppuhelper/source/propertysetmixin.cxx
+++ b/cppuhelper/source/propertysetmixin.cxx
@@ -66,6 +66,7 @@
 #include <com/sun/star/uno/TypeClass.hpp>
 #include <com/sun/star/uno/XComponentContext.hpp>
 #include <com/sun/star/uno/XInterface.hpp>
+#include <cppuhelper/exc_hlp.hxx>
 #include <cppuhelper/implbase.hxx>
 #include <cppuhelper/propertysetmixin.hxx>
 #include <cppuhelper/weak.hxx>
@@ -436,9 +437,11 @@ PropertySetMixinImpl::Impl::Impl(
                     m_type.getTypeName()),
             css::uno::UNO_QUERY_THROW);
     } catch (css::container::NoSuchElementException & e) {
-        throw css::uno::RuntimeException(
+        css::uno::Any anyEx = cppu::getCaughtException();
+        throw css::lang::WrappedTargetRuntimeException(
             "unexpected com.sun.star.container.NoSuchElementException: "
-             + e.Message);
+             + e.Message,
+             nullptr, anyEx );
     }
     std::vector< rtl::OUString > handleNames;
     initProperties(ifc, m_absentOptional, &handleNames);
@@ -509,10 +512,11 @@ void PropertySetMixinImpl::Impl::setProperty(
             throw css::lang::IllegalArgumentException(
                 e.Message, object, illegalArgumentPosition);
         } else {
-            throw css::uno::RuntimeException(
-                ("unexpected com.sun.star.lang.IllegalArgumentException: "
-                 + e.Message),
-                object);
+            css::uno::Any anyEx = cppu::getCaughtException();
+            throw css::lang::WrappedTargetRuntimeException(
+                "unexpected com.sun.star.lang.IllegalArgumentException: "
+                 + e.Message,
+                object, anyEx );
         }
     } catch (css::lang::IllegalAccessException &) {
         //TODO  Clarify whether PropertyVetoException is the correct exception
@@ -564,10 +568,11 @@ css::uno::Any PropertySetMixinImpl::Impl::getProperty(
     try {
         value = field->get(object->queryInterface(m_type));
     } catch (css::lang::IllegalArgumentException & e) {
-        throw css::uno::RuntimeException(
-            ("unexpected com.sun.star.lang.IllegalArgumentException: "
-             + e.Message),
-            object);
+        css::uno::Any anyEx = cppu::getCaughtException();
+        throw css::lang::WrappedTargetRuntimeException(
+            "unexpected com.sun.star.lang.IllegalArgumentException: "
+             + e.Message,
+             object, anyEx );
     } catch (css::lang::WrappedTargetRuntimeException & e) {
         //FIXME  A WrappedTargetRuntimeException from XIdlField2.get is not
         // guaranteed to originate directly within XIdlField2.get (and thus have
@@ -621,10 +626,11 @@ css::uno::Any PropertySetMixinImpl::Impl::getProperty(
                     ambiguous->getField("Value"), css::uno::UNO_QUERY_THROW)->
                     get(value);
             } catch (css::lang::IllegalArgumentException & e) {
-                throw css::uno::RuntimeException(
-                    ("unexpected com.sun.star.lang.IllegalArgumentException: "
-                     + e.Message),
-                    object);
+                css::uno::Any anyEx = cppu::getCaughtException();
+                throw css::lang::WrappedTargetRuntimeException(
+                    "unexpected com.sun.star.lang.IllegalArgumentException: "
+                     + e.Message,
+                     object, anyEx );
             }
             undoAmbiguous = false;
         } else if (undoDefaulted
@@ -649,10 +655,11 @@ css::uno::Any PropertySetMixinImpl::Impl::getProperty(
                     defaulted->getField("Value"), css::uno::UNO_QUERY_THROW)->
                     get(value);
             } catch (css::lang::IllegalArgumentException & e) {
-                throw css::uno::RuntimeException(
-                    ("unexpected com.sun.star.lang.IllegalArgumentException: "
-                     + e.Message),
-                    object);
+                css::uno::Any anyEx = cppu::getCaughtException();
+                throw css::lang::WrappedTargetRuntimeException(
+                    "unexpected com.sun.star.lang.IllegalArgumentException: "
+                     + e.Message,
+                    object, anyEx );
             }
             undoDefaulted = false;
         } else if (undoOptional
@@ -681,10 +688,11 @@ css::uno::Any PropertySetMixinImpl::Impl::getProperty(
                     optional->getField("Value"), css::uno::UNO_QUERY_THROW)->
                     get(value);
             } catch (css::lang::IllegalArgumentException & e) {
-                throw css::uno::RuntimeException(
-                    ("unexpected com.sun.star.lang.IllegalArgumentException: "
-                     + e.Message),
-                    object);
+                css::uno::Any anyEx = cppu::getCaughtException();
+                throw css::lang::WrappedTargetRuntimeException(
+                    "unexpected com.sun.star.lang.IllegalArgumentException: "
+                     + e.Message,
+                     object, anyEx );
             }
             undoOptional = false;
         } else {
@@ -738,15 +746,17 @@ css::uno::Any PropertySetMixinImpl::Impl::wrapValue(
                 type->getField("IsAmbiguous"), css::uno::UNO_QUERY_THROW)->set(
                     strct, css::uno::Any(isAmbiguous));
         } catch (css::lang::IllegalArgumentException & e) {
-            throw css::uno::RuntimeException(
-                ("unexpected com.sun.star.lang.IllegalArgumentException: "
-                 + e.Message),
-                object);
+            css::uno::Any anyEx = cppu::getCaughtException();
+            throw css::lang::WrappedTargetRuntimeException(
+                "unexpected com.sun.star.lang.IllegalArgumentException: "
+                 + e.Message,
+                 object, anyEx );
         } catch (css::lang::IllegalAccessException & e) {
-            throw css::uno::RuntimeException(
-                ("unexpected com.sun.star.lang.IllegalAccessException: "
-                 + e.Message),
-                object);
+            css::uno::Any anyEx = cppu::getCaughtException();
+            throw css::lang::WrappedTargetRuntimeException(
+                "unexpected com.sun.star.lang.IllegalAccessException: "
+                 + e.Message,
+                 object, anyEx );
         }
         return strct;
     }
@@ -767,15 +777,17 @@ css::uno::Any PropertySetMixinImpl::Impl::wrapValue(
                 type->getField("IsDefaulted"), css::uno::UNO_QUERY_THROW)->set(
                     strct, css::uno::Any(isDefaulted));
         } catch (css::lang::IllegalArgumentException & e) {
-            throw css::uno::RuntimeException(
-                ("unexpected com.sun.star.lang.IllegalArgumentException: "
-                 + e.Message),
-                object);
+            css::uno::Any anyEx = cppu::getCaughtException();
+            throw css::lang::WrappedTargetRuntimeException(
+                "unexpected com.sun.star.lang.IllegalArgumentException: "
+                 + e.Message,
+                 object, anyEx );
         } catch (css::lang::IllegalAccessException & e) {
-            throw css::uno::RuntimeException(
-                ("unexpected com.sun.star.lang.IllegalAccessException: "
-                 + e.Message),
-                object);
+            css::uno::Any anyEx = cppu::getCaughtException();
+            throw css::lang::WrappedTargetRuntimeException(
+                "unexpected com.sun.star.lang.IllegalAccessException: "
+                 + e.Message,
+                 object, anyEx );
         }
         return strct;
     }
@@ -799,15 +811,17 @@ css::uno::Any PropertySetMixinImpl::Impl::wrapValue(
                         isAmbiguous, wrapDefaulted, isDefaulted, false));
             }
         } catch (css::lang::IllegalArgumentException & e) {
-            throw css::uno::RuntimeException(
-                ("unexpected com.sun.star.lang.IllegalArgumentException: "
-                 + e.Message),
-                object);
+            css::uno::Any anyEx = cppu::getCaughtException();
+            throw css::lang::WrappedTargetRuntimeException(
+                "unexpected com.sun.star.lang.IllegalArgumentException: "
+                 + e.Message,
+                 object, anyEx );
         } catch (css::lang::IllegalAccessException & e) {
-            throw css::uno::RuntimeException(
-                ("unexpected com.sun.star.lang.IllegalAccessException: "
-                 + e.Message),
-                object);
+            css::uno::Any anyEx = cppu::getCaughtException();
+            throw css::lang::WrappedTargetRuntimeException(
+                "unexpected com.sun.star.lang.IllegalAccessException: "
+                 + e.Message,
+                object, anyEx );
         }
         return strct;
     }
diff --git a/dbaccess/source/core/api/CRowSetDataColumn.cxx b/dbaccess/source/core/api/CRowSetDataColumn.cxx
index 14970364a798..c11fe639bf25 100644
--- a/dbaccess/source/core/api/CRowSetDataColumn.cxx
+++ b/dbaccess/source/core/api/CRowSetDataColumn.cxx
@@ -113,9 +113,10 @@ void SAL_CALL ORowSetDataColumn::getFastPropertyValue( Any& rValue, sal_Int32 nH
         }
         catch(const SQLException &e)
         {
+            css::uno::Any anyEx = cppu::getCaughtException();
             throw WrappedTargetRuntimeException("Could not retrieve column value: " + e.Message,
                                                 *const_cast<ORowSetDataColumn*>(this),
-                                                Any(e));
+                                                anyEx);
         }
     }
     else if ( PROPERTY_ID_LABEL == nHandle && !m_sLabel.isEmpty() )
diff --git a/dbaccess/source/core/dataaccess/databasedocument.cxx b/dbaccess/source/core/dataaccess/databasedocument.cxx
index eee5e8465031..e147cf0281de 100644
--- a/dbaccess/source/core/dataaccess/databasedocument.cxx
+++ b/dbaccess/source/core/dataaccess/databasedocument.cxx
@@ -646,18 +646,21 @@ void SAL_CALL ODatabaseDocument::storeToRecoveryFile( const OUString& i_TargetLo
         // commit the root storage
         tools::stor::commitStorageIfWriteable( xTargetStorage );
     }
+    catch( const IOException& )
+    {
+        throw;
+    }
+    catch( const RuntimeException& )
+    {
+        throw;
+    }
+    catch( const WrappedTargetException& )
+    {
+        throw;
+    }
     catch( const Exception& )
     {
         Any aError = ::cppu::getCaughtException();
-        if  (   aError.isExtractableTo( ::cppu::UnoType< IOException >::get() )
-            ||  aError.isExtractableTo( ::cppu::UnoType< RuntimeException >::get() )
-            ||  aError.isExtractableTo( ::cppu::UnoType< WrappedTargetException >::get() )
-            )
-        {
-            // allowed to leave
-            throw;
-        }
-
         throw WrappedTargetException( OUString(), *this, aError );
     }
 }
diff --git a/dbaccess/source/core/dataaccess/definitioncontainer.cxx b/dbaccess/source/core/dataaccess/definitioncontainer.cxx
index 95b4676006ba..ae52ecc5e67b 100644
--- a/dbaccess/source/core/dataaccess/definitioncontainer.cxx
+++ b/dbaccess/source/core/dataaccess/definitioncontainer.cxx
@@ -30,6 +30,7 @@
 #include <comphelper/enumhelper.hxx>
 #include <cppuhelper/exc_hlp.hxx>
 #include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
+#include <com/sun/star/lang/WrappedTargetRuntimeException.hpp>
 #include <com/sun/star/lang/XComponent.hpp>
 #include <com/sun/star/ucb/CommandInfo.hpp>
 #include <com/sun/star/beans/XPropertySet.hpp>
@@ -619,10 +620,11 @@ void SAL_CALL ODefinitionContainer::propertyChange( const PropertyChangeEvent& e
             implRemove( sOldName );
             implAppend( sNewName, xContent );
         }
-        catch(const Exception&)
+        catch(const Exception& ex)
         {
-            DBG_UNHANDLED_EXCEPTION("dbaccess");
-            throw RuntimeException();
+            css::uno::Any anyEx = cppu::getCaughtException();
+            throw css::lang::WrappedTargetRuntimeException( ex.Message,
+                            nullptr, anyEx );
         }
         m_bInPropertyChange = false;
     }
diff --git a/dbaccess/source/filter/xml/xmlfilter.cxx b/dbaccess/source/filter/xml/xmlfilter.cxx
index 906a2bd69272..11b424901bc2 100644
--- a/dbaccess/source/filter/xml/xmlfilter.cxx
+++ b/dbaccess/source/filter/xml/xmlfilter.cxx
@@ -324,11 +324,13 @@ bool ODBFilter::implImport( const Sequence< PropertyValue >& rDescriptor )
                 if (!sStreamRelPath.isEmpty())
                     xStorage = xStorage->openStorageElement(sStreamRelPath, embed::ElementModes::READ);
             }
+            catch (const RuntimeException&)
+            {
+                throw;
+            }
             catch (const Exception&)
             {
                 Any aError = ::cppu::getCaughtException();
-                if  (aError.isExtractableTo(::cppu::UnoType<RuntimeException>::get()))
-                    throw;
                 throw lang::WrappedTargetRuntimeException(OUString(), *this, aError);
             }
         }
diff --git a/dbaccess/source/ui/control/tabletree.cxx b/dbaccess/source/ui/control/tabletree.cxx
index 31428879bf09..a285b7f9675a 100644
--- a/dbaccess/source/ui/control/tabletree.cxx
+++ b/dbaccess/source/ui/control/tabletree.cxx
@@ -167,10 +167,9 @@ void OTableTreeListBox::UpdateTableList( const Reference< XConnection >& _rxConn
     }
     catch(Exception&)
     {
+        css::uno::Any anyEx = cppu::getCaughtException();
         // a non-SQLException exception occurred ... simply throw an SQLException
-        SQLException aInfo;
-        aInfo.Message = sCurrentActionError;
-        throw aInfo;
+        throw SQLException(sCurrentActionError, nullptr, "", 0, anyEx);
     }
 
     UpdateTableList( _rxConnection, sTables, sViews );
diff --git a/dbaccess/source/ui/dlg/DbAdminImpl.cxx b/dbaccess/source/ui/dlg/DbAdminImpl.cxx
index 49cdf5756619..0cce73ebbba6 100644
--- a/dbaccess/source/ui/dlg/DbAdminImpl.cxx
+++ b/dbaccess/source/ui/dlg/DbAdminImpl.cxx
@@ -388,11 +388,11 @@ Reference< XDriver > ODbDataSourceAdministrationHelper::getDriver(const OUString
     {
         xDriverManager.set( ConnectionPool::create( getORB() ) );
     }
-    catch (const Exception& e)
+    catch (const Exception&)
     {
+        css::uno::Any anyEx = cppu::getCaughtException();
         // wrap the exception into an SQLException
-        SQLException aSQLWrapper(e.Message, getORB(), "S1000", 0, Any());
-        throw SQLException(sCurrentActionError, getORB(), "S1000", 0, makeAny(aSQLWrapper));
+        throw SQLException(sCurrentActionError, getORB(), "S1000", 0, anyEx);
     }
 
     Reference< XDriver > xDriver = xDriverManager->getDriverByURL(_sURL);
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);
 }
diff --git a/embeddedobj/source/commonembedding/embedobj.cxx b/embeddedobj/source/commonembedding/embedobj.cxx
index 5eb943273fdf..8ec68838800f 100644
--- a/embeddedobj/source/commonembedding/embedobj.cxx
+++ b/embeddedobj/source/commonembedding/embedobj.cxx
@@ -38,6 +38,7 @@
 #include <com/sun/star/lang/DisposedException.hpp>
 
 #include <com/sun/star/embed/EmbedMisc.hpp>
+#include <cppuhelper/exc_hlp.hxx>
 #include <cppuhelper/interfacecontainer.hxx>
 #include <comphelper/lok.hxx>
 
@@ -100,12 +101,13 @@ void OCommonEmbeddedObject::Deactivate()
         catch( const embed::ObjectSaveVetoException& )
         {
         }
-        catch( const uno::Exception& e )
+        catch( const uno::Exception& )
         {
+            css::uno::Any anyEx = cppu::getCaughtException();
             throw embed::StorageWrappedTargetException(
                 "The client could not store the object!",
                 static_cast< ::cppu::OWeakObject* >( this ),
-                uno::makeAny( e ) );
+                anyEx );
         }
     }
 
diff --git a/embeddedobj/source/commonembedding/persistence.cxx b/embeddedobj/source/commonembedding/persistence.cxx
index e8eaee6d59eb..999ccd28955d 100644
--- a/embeddedobj/source/commonembedding/persistence.cxx
+++ b/embeddedobj/source/commonembedding/persistence.cxx
@@ -138,12 +138,13 @@ uno::Reference< io::XInputStream > createTempInpStreamFromStor(
     try
     {
         xStorage->copyToStorage( xTempStorage );
-    } catch( const uno::Exception& e )
+    } catch( const uno::Exception& )
     {
+        css::uno::Any anyEx = cppu::getCaughtException();
         throw embed::StorageWrappedTargetException(
                     "Can't copy storage!",
                     uno::Reference< uno::XInterface >(),
-                    uno::makeAny( e ) );
+                    anyEx );
     }
 
     try {
diff --git a/embeddedobj/source/msole/oleembed.cxx b/embeddedobj/source/msole/oleembed.cxx
index 64d95c3d7a56..e9078734d2a9 100644
--- a/embeddedobj/source/msole/oleembed.cxx
+++ b/embeddedobj/source/msole/oleembed.cxx
@@ -33,6 +33,7 @@
 #include <com/sun/star/io/TempFile.hpp>
 #include <com/sun/star/io/XSeekable.hpp>
 #include <com/sun/star/lang/DisposedException.hpp>
+#include <com/sun/star/lang/WrappedTargetRuntimeException.hpp>
 #include <com/sun/star/beans/NamedValue.hpp>
 #include <com/sun/star/beans/XPropertySet.hpp>
 #include <com/sun/star/frame/XLoadable.hpp>
@@ -43,6 +44,7 @@
 #include <com/sun/star/system/SystemShellExecute.hpp>
 #include <com/sun/star/system/SystemShellExecuteFlags.hpp>
 
+#include <cppuhelper/exc_hlp.hxx>
 #include <cppuhelper/interfacecontainer.h>
 #include <comphelper/processfactory.hxx>
 #include <comphelper/mimeconfighelper.hxx>
@@ -382,14 +384,16 @@ bool OleEmbeddedObject::TryToConvertToOOo( const uno::Reference< io::XStream >&
                         m_xParentStorage->removeElement( m_aEntryName );
                     m_xParentStorage->renameElement( aTmpStreamName, m_aEntryName );
                 }
-                catch ( const uno::Exception& )
+                catch ( const uno::Exception& ex )
                 {
+                    css::uno::Any anyEx = cppu::getCaughtException();
                     try {
                         close( true );
                     } catch( const uno::Exception& ) {}
 
                     m_xParentStorage->dispose(); // ??? the storage has information loss, it should be closed without committing!
-                    throw uno::RuntimeException(); // the repairing is not possible
+                    throw css::lang::WrappedTargetRuntimeException( ex.Message,
+                                    nullptr, anyEx ); // the repairing is not possible
                 }
             SAL_FALLTHROUGH;
             case 2:
@@ -398,13 +402,15 @@ bool OleEmbeddedObject::TryToConvertToOOo( const uno::Reference< io::XStream >&
                     m_xObjectStream = m_xParentStorage->openStreamElement( m_aEntryName, m_bReadOnly ? embed::ElementModes::READ : embed::ElementModes::READWRITE );
                     m_nObjectState = embed::EmbedStates::LOADED;
                 }
-                catch( const uno::Exception& )
+                catch( const uno::Exception& ex )
                 {
+                    css::uno::Any anyEx = cppu::getCaughtException();
                     try {
                         close( true );
                     } catch( const uno::Exception& ) {}
 
-                    throw uno::RuntimeException(); // the repairing is not possible
+                    throw css::lang::WrappedTargetRuntimeException( ex.Message,
+                                    nullptr, anyEx ); // the repairing is not possible
                 }
                 SAL_FALLTHROUGH;
 
diff --git a/eventattacher/source/eventattacher.cxx b/eventattacher/source/eventattacher.cxx
index 758189f65307..045d9d968036 100644
--- a/eventattacher/source/eventattacher.cxx
+++ b/eventattacher/source/eventattacher.cxx
@@ -37,6 +37,7 @@
 // InvocationToAllListenerMapper
 #include <com/sun/star/script/XInvocation.hpp>
 #include <comphelper/processfactory.hxx>
+#include <cppuhelper/exc_hlp.hxx>
 #include <cppuhelper/weak.hxx>
 #include <cppuhelper/factory.hxx>
 #include <cppuhelper/implbase.hxx>
@@ -510,9 +511,10 @@ Any SAL_CALL FilterAllListenerImpl::approveFiring( const AllEventObject& Event )
                 convertToEventReturn( aRet, aRetType );
             }
         }
-        catch( const CannotConvertException& e )
+        catch( const CannotConvertException& )
         {
-            throw InvocationTargetException( OUString(), Reference< XInterface >(), Any(&e, cppu::UnoType<CannotConvertException>::get()) );
+            css::uno::Any anyEx = cppu::getCaughtException();
+            throw InvocationTargetException( OUString(), Reference< XInterface >(), anyEx );
         }
     }
     return aRet;
diff --git a/extensions/source/ole/oleobjw.cxx b/extensions/source/ole/oleobjw.cxx
index 8238088e641f..73ef6bd60df1 100644
--- a/extensions/source/ole/oleobjw.cxx
+++ b/extensions/source/ole/oleobjw.cxx
@@ -29,11 +29,13 @@
 #include <com/sun/star/script/CannotConvertException.hpp>
 #include <com/sun/star/script/FailReason.hpp>
 #include <com/sun/star/beans/XMaterialHolder.hpp>
+#include <com/sun/star/lang/WrappedTargetRuntimeException.hpp>
 #include <com/sun/star/script/XInvocation.hpp>
 #include <com/sun/star/bridge/ModelDependent.hpp>
 
 #include <com/sun/star/bridge/oleautomation/NamedArgument.hpp>
 #include <com/sun/star/bridge/oleautomation/PropertyPutArgument.hpp>
+#include <cppuhelper/exc_hlp.hxx>
 
 #include <typelib/typedescription.hxx>
 #include <rtl/uuid.h>
@@ -158,9 +160,11 @@ Any SAL_CALL IUnknownWrapper::invokeGetProperty( const OUString& aPropertyName,
     }
     catch ( const Exception& e )
     {
-       throw RuntimeException("[automation bridge] unexpected exception in "
-               "IUnknownWrapper::invokeGetProperty ! Message : \n" +
-                e.Message);
+        css::uno::Any anyEx = cppu::getCaughtException();
+        throw css::lang::WrappedTargetRuntimeException("[automation bridge] unexpected exception in "
+                "IUnknownWrapper::invokeGetProperty ! Message : \n " +
+                e.Message,
+                nullptr, anyEx );
     }
     return aResult;
 }
@@ -186,9 +190,11 @@ Any SAL_CALL IUnknownWrapper::invokePutProperty( const OUString& aPropertyName,
     }
     catch ( const Exception& e )
     {
-       throw RuntimeException("[automation bridge] unexpected exception in "
-               "IUnknownWrapper::invokePutProperty ! Message : \n" +
-                e.Message);
+        css::uno::Any anyEx = cppu::getCaughtException();
+        throw css::lang::WrappedTargetRuntimeException("[automation bridge] unexpected exception in "
+                "IUnknownWrapper::invokePutProperty ! Message : \n" +
+                e.Message,
+                nullptr, anyEx );
     }
     return aResult;
 }
@@ -241,9 +247,11 @@ Any SAL_CALL IUnknownWrapper::invoke( const OUString& aFunctionName,
     }
     catch (const Exception & e)
     {
-        throw RuntimeException("[automation bridge] unexpected exception in "
-                                     "IUnknownWrapper::invoke ! Message : \n" +
-                               e.Message);
+        css::uno::Any anyEx = cppu::getCaughtException();
+        throw css::lang::WrappedTargetRuntimeException("[automation bridge] unexpected exception in "
+                "IUnknownWrapper::invoke ! Message : \n" +
+                e.Message,
+                nullptr, anyEx );
 
     }
     catch(...)
@@ -408,9 +416,11 @@ void SAL_CALL IUnknownWrapper::setValue( const OUString& aPropertyName,
     }
     catch (const Exception & e)
     {
-        throw RuntimeException("[automation bridge] unexpected exception in "
-                               "IUnknownWrapper::setValue ! Message : \n" +
-                               e.Message);
+        css::uno::Any anyEx = cppu::getCaughtException();
+        throw css::lang::WrappedTargetRuntimeException("[automation bridge] unexpected exception in "
+                "IUnknownWrapper::setValue ! Message : \n" +
+                e.Message,
+                nullptr, anyEx );
 
     }
     catch (...)
@@ -550,9 +560,11 @@ Any SAL_CALL IUnknownWrapper::getValue( const OUString& aPropertyName )
     }
     catch (const Exception & e)
     {
-        throw RuntimeException("[automation bridge] unexpected exception in "
-                               "IUnknownWrapper::getValue ! Message : \n" +
-                               e.Message);
+        css::uno::Any anyEx = cppu::getCaughtException();
+        throw css::lang::WrappedTargetRuntimeException("[automation bridge] unexpected exception in "
+                "IUnknownWrapper::getValue ! Message : \n" +
+                e.Message,
+                nullptr, anyEx );
     }
     catch (...)
     {
@@ -599,9 +611,11 @@ sal_Bool SAL_CALL IUnknownWrapper::hasMethod( const OUString& aName )
     }
     catch (const Exception & e)
     {
-        throw RuntimeException("[automation bridge] unexpected exception in "
-                               "IUnknownWrapper::hasMethod ! Message : \n" +
-                               e.Message);
+        css::uno::Any anyEx = cppu::getCaughtException();
+        throw css::lang::WrappedTargetRuntimeException("[automation bridge] unexpected exception in "
+                "IUnknownWrapper::hasMethod ! Message : \n" +
+                e.Message,
+                nullptr, anyEx );
     }
     catch (...)
     {
@@ -648,9 +662,11 @@ sal_Bool SAL_CALL IUnknownWrapper::hasProperty( const OUString& aName )
     }
     catch (const Exception & e)
     {
-        throw RuntimeException("[automation bridge] unexpected exception in "
-                               "IUnknownWrapper::hasProperty ! Message : \n" +
-                               e.Message);
+        css::uno::Any anyEx = cppu::getCaughtException();
+        throw css::lang::WrappedTargetRuntimeException("[automation bridge] unexpected exception in "
+                "IUnknownWrapper::hasProperty ! Message : \n" +
+                e.Message,
+                nullptr, anyEx );
 
     }
     catch (...)
@@ -1211,8 +1227,10 @@ void SAL_CALL IUnknownWrapper::initialize( const Sequence< Any >& aArguments )
         }
         catch( const Exception& e )
         {
-            throw RuntimeException(
-                    "[automation bridge] unexpected exception in IUnknownWrapper::initialize() error message: \n" + e.Message );
+            css::uno::Any anyEx = cppu::getCaughtException();
+            throw css::lang::WrappedTargetRuntimeException(
+                    "[automation bridge] unexpected exception in IUnknownWrapper::initialize() error message: \n" + e.Message,
+                    nullptr, anyEx );
         }
     }
 }
diff --git a/extensions/source/update/feed/updatefeed.cxx b/extensions/source/update/feed/updatefeed.cxx
index e42f064d156f..6998da2f941b 100644
--- a/extensions/source/update/feed/updatefeed.cxx
+++ b/extensions/source/update/feed/updatefeed.cxx
@@ -19,6 +19,7 @@
 
 #include <config_folders.h>
 
+#include <cppuhelper/exc_hlp.hxx>
 #include <cppuhelper/implbase.hxx>
 #include <cppuhelper/implementationentry.hxx>
 #include <cppuhelper/supportsservice.hxx>
@@ -255,17 +256,23 @@ public:
 
             return uno::makeAny(aEntry);
         }
-
-        // action has been aborted
-        catch( ucb::CommandAbortedException const & e)
-            { throw lang::WrappedTargetException( "Command aborted", *this, uno::makeAny(e) ); }
-
-        // let runtime exception pass
-        catch( uno::RuntimeException const & ) { throw; }
-
-        // document not accessible
-        catch( uno::Exception const & e)
-            { throw lang::WrappedTargetException( "Document not accessible", *this, uno::makeAny(e) ); }
+        catch( ucb::CommandAbortedException const &)
+        {
+            // action has been aborted
+            css::uno::Any anyEx = cppu::getCaughtException();
+            throw lang::WrappedTargetException( "Command aborted", *this, anyEx );
+        }
+        catch( uno::RuntimeException const & )
+        {
+            // let runtime exception pass
+            throw;
+        }
+        catch( uno::Exception const &)
+        {
+            // document not accessible
+            css::uno::Any anyEx = cppu::getCaughtException();
+            throw lang::WrappedTargetException( "Document not accessible", *this, anyEx );
+        }
     }
 
 private:
diff --git a/forms/source/component/clickableimage.cxx b/forms/source/component/clickableimage.cxx
index ab3cfe52d83b..d110b36f1524 100644
--- a/forms/source/component/clickableimage.cxx
+++ b/forms/source/component/clickableimage.cxx
@@ -43,6 +43,7 @@
 #include <osl/mutex.hxx>
 #include <services.hxx>
 #include <comphelper/listenernotification.hxx>
+#include <cppuhelper/exc_hlp.hxx>
 #include <svtools/imageresourceaccess.hxx>
 #define LOCAL_URL_PREFIX    '#'
 
@@ -422,10 +423,11 @@ namespace frm
             // allowed to leave
             throw;
         }
-        catch( const Exception& e )
+        catch( const Exception& )
         {
+            css::uno::Any anyEx = cppu::getCaughtException();
             OSL_FAIL( "OClickableImageBaseControl::implSubmit: caught an unknown exception!" );
-            throw WrappedTargetException( OUString(), *this, makeAny( e ) );
+            throw WrappedTargetException( OUString(), *this, anyEx );
         }
     }
 
diff --git a/forms/source/xforms/submission.cxx b/forms/source/xforms/submission.cxx
index 3757378c663d..08e04b8b2a33 100644
--- a/forms/source/xforms/submission.cxx
+++ b/forms/source/xforms/submission.cxx
@@ -45,6 +45,7 @@
 #include <com/sun/star/task/XInteractionContinuation.hpp>
 #include <com/sun/star/xforms/InvalidDataOnSubmitException.hpp>
 #include <com/sun/star/frame/XFrame.hpp>
+#include <cppuhelper/exc_hlp.hxx>
 #include <cppuhelper/typeprovider.hxx>
 #include <comphelper/propertysetinfo.hxx>
 #include <comphelper/interaction.hxx>
@@ -469,12 +470,13 @@ void SAL_CALL Submission::submitWithInteraction(
         // allowed to leave
         throw;
     }
-    catch( const Exception& e )
+    catch( const Exception& )
     {
+        css::uno::Any anyEx = cppu::getCaughtException();
         // exception caught: re-throw as wrapped target exception
         throw WrappedTargetException(
             lcl_message( sID, " due to exception being thrown" ),
-            *this, makeAny( e ) );
+            *this, anyEx );
     }
 
     if( !bResult )
diff --git a/framework/source/accelerators/storageholder.cxx b/framework/source/accelerators/storageholder.cxx
index 1cf4ca98719d..99c67af297e0 100644
--- a/framework/source/accelerators/storageholder.cxx
+++ b/framework/source/accelerators/storageholder.cxx
@@ -383,7 +383,6 @@ css::uno::Reference< css::embed::XStorage > StorageHolder::openSubStorageWithFal
 {
     // a) try it first with user specified open mode
     //    ignore errors ... but save it for later use!
-    css::uno::Exception exResult;
     try
     {
         css::uno::Reference< css::embed::XStorage > xSubStorage = xBaseStorage->openStorageElement(sSubStorage, eOpenMode);
@@ -391,13 +390,19 @@ css::uno::Reference< css::embed::XStorage > StorageHolder::openSubStorageWithFal
             return xSubStorage;
     }
     catch(const css::uno::RuntimeException&)
-        { throw; }
-    catch(const css::uno::Exception& ex)
-        { exResult = ex; }
+    {
+        throw;
+    }
+    catch(const css::uno::Exception&)
+    {
+        // b) readonly already tried? => forward last error!
+        if ((eOpenMode & css::embed::ElementModes::WRITE) != css::embed::ElementModes::WRITE) // fallback possible ?
+            throw;
+    }
 
-    // b) readonly already tried? => forward last error!
+    // b) readonly already tried, throw error
     if ((eOpenMode & css::embed::ElementModes::WRITE) != css::embed::ElementModes::WRITE) // fallback possible ?
-        throw exResult;
+        throw css::uno::Exception();
 
     // c) try it readonly
     //    don't catch exception here! Outside code wish to know, if operation failed or not.
diff --git a/framework/source/fwe/xml/menuconfiguration.cxx b/framework/source/fwe/xml/menuconfiguration.cxx
index 1057119bc572..b4d8c7164c00 100644
--- a/framework/source/fwe/xml/menuconfiguration.cxx
+++ b/framework/source/fwe/xml/menuconfiguration.cxx
@@ -30,6 +30,7 @@
 #include <com/sun/star/xml/sax/Writer.hpp>
 #include <com/sun/star/io/IOException.hpp>
 #include <com/sun/star/io/XActiveDataSource.hpp>
+#include <cppuhelper/exc_hlp.hxx>
 
 using namespace ::com::sun::star::uno;
 using namespace ::com::sun::star::lang;
@@ -80,20 +81,23 @@ Reference< XIndexAccess > MenuConfiguration::CreateMenuBarConfigurationFromXML(
     }
     catch ( const RuntimeException& e )
     {
-        throw WrappedTargetException( e.Message, Reference< XInterface >(), Any() );
+        css::uno::Any anyEx = cppu::getCaughtException();
+        throw WrappedTargetException( e.Message, Reference< XInterface >(), anyEx );
     }
     catch( const SAXException& e )
     {
+        css::uno::Any anyEx = cppu::getCaughtException();
         SAXException aWrappedSAXException;
 
         if ( !( e.WrappedException >>= aWrappedSAXException ))
-            throw WrappedTargetException( e.Message, Reference< XInterface >(), Any() );
+            throw WrappedTargetException( e.Message, Reference< XInterface >(), anyEx );
         else
-            throw WrappedTargetException( aWrappedSAXException.Message, Reference< XInterface >(), Any() );
+            throw WrappedTargetException( aWrappedSAXException.Message, Reference< XInterface >(), e.WrappedException );
     }
     catch( const css::io::IOException& e )
     {
-        throw WrappedTargetException( e.Message, Reference< XInterface >(), Any() );
+        css::uno::Any anyEx = cppu::getCaughtException();
+        throw WrappedTargetException( e.Message, Reference< XInterface >(), anyEx );
     }
 }
 
@@ -111,15 +115,18 @@ void MenuConfiguration::StoreMenuBarConfigurationToXML(
     }
     catch ( const RuntimeException& e )
     {
-        throw WrappedTargetException( e.Message, Reference< XInterface >(), Any() );
+        css::uno::Any anyEx = cppu::getCaughtException();
+        throw WrappedTargetException( e.Message, Reference< XInterface >(), anyEx );
     }
     catch ( const SAXException& e )
     {
-        throw WrappedTargetException( e.Message, Reference< XInterface >(), Any() );
+        css::uno::Any anyEx = cppu::getCaughtException();
+        throw WrappedTargetException( e.Message, Reference< XInterface >(), anyEx );
     }
     catch ( const css::io::IOException& e )
     {
-        throw WrappedTargetException( e.Message, Reference< XInterface >(), Any() );
+        css::uno::Any anyEx = cppu::getCaughtException();
+        throw WrappedTargetException( e.Message, Reference< XInterface >(), anyEx );
     }
 }
 
diff --git a/framework/source/uiconfiguration/moduleuiconfigurationmanager.cxx b/framework/source/uiconfiguration/moduleuiconfigurationmanager.cxx
index 26e462495e16..229b5392b640 100644
--- a/framework/source/uiconfiguration/moduleuiconfigurationmanager.cxx
+++ b/framework/source/uiconfiguration/moduleuiconfigurationmanager.cxx
@@ -51,6 +51,7 @@
 
 #include <comphelper/propertysequence.hxx>
 #include <comphelper/sequence.hxx>
+#include <cppuhelper/exc_hlp.hxx>
 #include <cppuhelper/implbase.hxx>
 #include <cppuhelper/interfacecontainer.hxx>
 #include <cppuhelper/supportsservice.hxx>
@@ -1022,12 +1023,12 @@ void SAL_CALL ModuleUIConfigurationManager::reset()
                     impl_resetElementTypeData( rUserElementType, rDefaultElementType, aRemoveEventNotifyContainer, aReplaceEventNotifyContainer );
                     rUserElementType.bModified = false;
                 }
-                catch (const Exception& e)
+                catch (const Exception&)
                 {
-                    css::uno::Any a(e);
+                    css::uno::Any anyEx = cppu::getCaughtException();
                     throw css::lang::WrappedTargetRuntimeException(
                             "ModuleUIConfigurationManager::reset exception",
-                            css::uno::Reference<css::uno::XInterface>(*this), a);
+                            css::uno::Reference<css::uno::XInterface>(*this), anyEx);
                 }
             }
 
diff --git a/jvmaccess/Library_jvmaccess.mk b/jvmaccess/Library_jvmaccess.mk
index 0a0fc2312e15..b4ef50a7d427 100644
--- a/jvmaccess/Library_jvmaccess.mk
+++ b/jvmaccess/Library_jvmaccess.mk
@@ -19,6 +19,7 @@ $(eval $(call gb_Library_use_api,jvmaccess,\
 
 $(eval $(call gb_Library_use_libraries,jvmaccess,\
     cppu \
+    cppuhelper \
     sal \
     salhelper \
 ))
diff --git a/jvmaccess/source/classpath.cxx b/jvmaccess/source/classpath.cxx
index 4be1fedb7d26..c1a0d165f397 100644
--- a/jvmaccess/source/classpath.cxx
+++ b/jvmaccess/source/classpath.cxx
@@ -25,6 +25,7 @@
 #include <vector>
 
 #include <com/sun/star/lang/IllegalArgumentException.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/XComponentContext.hpp>
@@ -32,6 +33,7 @@
 #include <com/sun/star/uri/UriReferenceFactory.hpp>
 #include <com/sun/star/uri/XVndSunStarExpandUrlReference.hpp>
 #include <com/sun/star/util/theMacroExpander.hpp>
+#include <cppuhelper/exc_hlp.hxx>
 #include <rtl/ustring.hxx>
 #include <sal/types.h>
 
@@ -66,9 +68,11 @@ jobjectArray jvmaccess::ClassPath::translateToUrls(
                 try {
                     url = expUrl->expand( expander );
                 } catch (const css::lang::IllegalArgumentException & e) {
-                    throw css::uno::RuntimeException(
+                    css::uno::Any anyEx = cppu::getCaughtException();
+                    throw css::lang::WrappedTargetRuntimeException(
                         "com.sun.star.lang.IllegalArgumentException: "
-                         + e.Message);
+                         + e.Message,
+                         nullptr, anyEx );
                 }
             }
             jvalue arg;
diff --git a/oox/source/docprop/docprophandler.cxx b/oox/source/docprop/docprophandler.cxx
index ae8d4829a91c..26d7e32443f7 100644
--- a/oox/source/docprop/docprophandler.cxx
+++ b/oox/source/docprop/docprophandler.cxx
@@ -24,6 +24,7 @@
 #include <com/sun/star/lang/IllegalArgumentException.hpp>
 #include <com/sun/star/lang/Locale.hpp>
 #include <com/sun/star/xml/sax/SAXException.hpp>
+#include <cppuhelper/exc_hlp.hxx>
 
 #include <o3tl/safeint.hxx>
 #include <osl/time.h>
@@ -676,12 +677,13 @@ void SAL_CALL OOXMLDocPropHandler::characters( const OUString& aChars )
     {
         throw;
     }
-    catch( uno::Exception& e )
+    catch( uno::Exception& )
     {
+        css::uno::Any anyEx = cppu::getCaughtException();
         throw xml::sax::SAXException(
             "Error while setting document property!",
             uno::Reference< uno::XInterface >(),
-            uno::makeAny( e ) );
+            anyEx );
     }
 }
 
diff --git a/package/source/manifest/ManifestWriter.cxx b/package/source/manifest/ManifestWriter.cxx
index d349eaadeaa6..bedb6121d37c 100644
--- a/package/source/manifest/ManifestWriter.cxx
+++ b/package/source/manifest/ManifestWriter.cxx
@@ -19,11 +19,13 @@
 
 #include "ManifestWriter.hxx"
 #include "ManifestExport.hxx"
+#include <cppuhelper/exc_hlp.hxx>
 #include <comphelper/processfactory.hxx>
 #include <cppuhelper/factory.hxx>
 #include <cppuhelper/supportsservice.hxx>
 #include <com/sun/star/io/XActiveDataSource.hpp>
 #include <com/sun/star/xml/sax/Writer.hpp>
+#include <com/sun/star/lang/WrappedTargetRuntimeException.hpp>
 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
 #include <com/sun/star/lang/XSingleServiceFactory.hpp>
 #include <com/sun/star/xml/sax/SAXException.hpp>
@@ -63,7 +65,9 @@ void SAL_CALL ManifestWriter::writeManifestSequence( const Reference< XOutputStr
     }
     catch( SAXException& )
     {
-        throw RuntimeException( THROW_WHERE );
+        css::uno::Any anyEx = cppu::getCaughtException();
+        throw css::lang::WrappedTargetRuntimeException( THROW_WHERE,
+                        nullptr, anyEx );
     }
 }
 
diff --git a/package/source/xstor/ohierarchyholder.cxx b/package/source/xstor/ohierarchyholder.cxx
index c07c7740c502..508107ac7c53 100644
--- a/package/source/xstor/ohierarchyholder.cxx
+++ b/package/source/xstor/ohierarchyholder.cxx
@@ -27,6 +27,7 @@
 #include <com/sun/star/embed/XTransactionBroadcaster.hpp>
 #include <com/sun/star/lang/IllegalArgumentException.hpp>
 #include <com/sun/star/lang/WrappedTargetRuntimeException.hpp>
+#include <cppuhelper/exc_hlp.hxx>
 
 #include "ohierarchyholder.hxx"
 
@@ -275,9 +276,11 @@ void SAL_CALL OHierarchyElement_Impl::disposing( const lang::EventObject& Source
 
         TestForClosing();
     }
-    catch( uno::Exception& )
+    catch( uno::Exception& ex )
     {
-        throw uno::RuntimeException(); // no exception must happen here, usually an exception means disaster
+        css::uno::Any anyEx = cppu::getCaughtException();
+        throw lang::WrappedTargetRuntimeException( ex.Message,
+                        nullptr, anyEx ); // no exception must happen here, usually an exception means disaster
     }
 }
 
@@ -309,12 +312,13 @@ void SAL_CALL OHierarchyElement_Impl::commited( const css::lang::EventObject& /*
     {
         Commit();
     }
-    catch( const uno::Exception& e )
+    catch( const uno::Exception& )
     {
+        css::uno::Any anyEx = cppu::getCaughtException();
         throw lang::WrappedTargetRuntimeException(
                             "Can not commit storage sequence!",
                             uno::Reference< uno::XInterface >(),
-                            uno::makeAny( e ) );
+                            anyEx );
     }
 }
 
diff --git a/package/source/zippackage/ZipPackage.cxx b/package/source/zippackage/ZipPackage.cxx
index a04580dcaeae..45eda6d4837e 100644
--- a/package/source/zippackage/ZipPackage.cxx
+++ b/package/source/zippackage/ZipPackage.cxx
@@ -1037,12 +1037,13 @@ void ZipPackage::WriteMimetypeMagicFile( ZipOutputStream& aZipOut )
         aZipOut.rawWrite(aType);
         aZipOut.rawCloseEntry();
     }
-    catch ( const css::io::IOException & r )
+    catch ( const css::io::IOException & )
     {
+        css::uno::Any anyEx = cppu::getCaughtException();
         throw WrappedTargetException(
                 THROW_WHERE "Error adding mimetype to the ZipOutputStream!",
                 static_cast < OWeakObject * > ( this ),
-                makeAny( r ) );
+                anyEx );
     }
 }
 
@@ -1432,10 +1433,11 @@ void SAL_CALL ZipPackage::commitChanges()
     {
         xTempInStream = writeTempFile();
     }
-    catch (const ucb::ContentCreationException& r)
+    catch (const ucb::ContentCreationException&)
     {
+       css::uno::Any anyEx = cppu::getCaughtException();
         throw WrappedTargetException(THROW_WHERE "Temporary file should be creatable!",
-                    static_cast < OWeakObject * > ( this ), makeAny ( r ) );
+                    static_cast < OWeakObject * > ( this ), anyEx );
     }
     if ( xTempInStream.is() )
     {
@@ -1445,10 +1447,11 @@ void SAL_CALL ZipPackage::commitChanges()
         {
             xTempSeek->seek( 0 );
         }
-        catch( const uno::Exception& r )
+        catch( const uno::Exception& )
         {
+            css::uno::Any anyEx = cppu::getCaughtException();
             throw WrappedTargetException(THROW_WHERE "Temporary file should be seekable!",
-                    static_cast < OWeakObject * > ( this ), makeAny ( r ) );
+                    static_cast < OWeakObject * > ( this ), anyEx );
         }
 
         try
@@ -1456,10 +1459,11 @@ void SAL_CALL ZipPackage::commitChanges()
             // connect to the temporary stream
             ConnectTo( xTempInStream );
         }
-        catch( const io::IOException& r )
+        catch( const io::IOException& )
         {
+            css::uno::Any anyEx = cppu::getCaughtException();
             throw WrappedTargetException(THROW_WHERE "Temporary file should be connectable!",
-                    static_cast < OWeakObject * > ( this ), makeAny ( r ) );
+                    static_cast < OWeakObject * > ( this ), anyEx );
         }
 
         if ( m_eMode == e_IMode_XStream )
@@ -1484,10 +1488,11 @@ void SAL_CALL ZipPackage::commitChanges()
                 // after successful truncation the original file contents are already lost
                 xTruncate->truncate();
             }
-            catch( const uno::Exception& r )
+            catch( const uno::Exception& )
             {
+                css::uno::Any anyEx = cppu::getCaughtException();
                 throw WrappedTargetException(THROW_WHERE "This package is read only!",
-                        static_cast < OWeakObject * > ( this ), makeAny ( r ) );
+                        static_cast < OWeakObject * > ( this ), anyEx );
             }
 
             try
@@ -1579,15 +1584,16 @@ void SAL_CALL ZipPackage::commitChanges()
                     // if the file is still not corrupted, it can become after the next step
                     aContent.executeCommand ("transfer", Any(aInfo) );
                 }
-                catch ( const css::uno::Exception& r )
+                catch ( const css::uno::Exception& )
                 {
                     if ( bCanBeCorrupted )
                         DisconnectFromTargetAndThrowException_Impl( xTempInStream );
 
+                    css::uno::Any anyEx = cppu::getCaughtException();
                     throw WrappedTargetException(
                                                 THROW_WHERE "This package may be read only!",
                                                 static_cast < OWeakObject * > ( this ),
-                                                makeAny ( r ) );
+                                                anyEx );
                 }
             }
         }
diff --git a/package/source/zippackage/zipfileaccess.cxx b/package/source/zippackage/zipfileaccess.cxx
index eb5ad53f1ce7..f2b1015a7055 100644
--- a/package/source/zippackage/zipfileaccess.cxx
+++ b/package/source/zippackage/zipfileaccess.cxx
@@ -25,6 +25,7 @@
 #include <com/sun/star/io/XSeekable.hpp>
 #include <com/sun/star/beans/NamedValue.hpp>
 #include <comphelper/processfactory.hxx>
+#include <cppuhelper/exc_hlp.hxx>
 #include <cppuhelper/supportsservice.hxx>
 #include <zipfileaccess.hxx>
 #include <ZipEnumeration.hxx>
@@ -282,11 +283,11 @@ uno::Any SAL_CALL OZipFileAccess::getByName( const OUString& aName )
     {
         throw;
     }
-    catch (const uno::Exception& e)
+    catch (const uno::Exception&)
     {
+        css::uno::Any anyEx = cppu::getCaughtException();
         throw lang::WrappedTargetException( "This package is unusable!",
-                  static_cast < OWeakObject * > ( this ),
-                                        makeAny(e));
+                  static_cast < OWeakObject * > ( this ), anyEx);
     }
 
     if ( !xEntryStream.is() )
diff --git a/pyuno/source/module/pyuno_adapter.cxx b/pyuno/source/module/pyuno_adapter.cxx
index 0a18a48ae75b..1461d1adec48 100644
--- a/pyuno/source/module/pyuno_adapter.cxx
+++ b/pyuno/source/module/pyuno_adapter.cxx
@@ -26,6 +26,7 @@
 #include <com/sun/star/beans/MethodConcept.hpp>
 #include <com/sun/star/beans/UnknownPropertyException.hpp>
 
+#include <cppuhelper/exc_hlp.hxx>
 #include <cppuhelper/typeprovider.hxx>
 
 
@@ -378,7 +379,8 @@ void Adapter::setValue( const OUString & aPropertyName, const Any & value )
     }
     catch( const IllegalArgumentException & exc )
     {
-        throw InvocationTargetException( exc.Message, *this, css::uno::makeAny( exc ) );
+        css::uno::Any anyEx = cppu::getCaughtException();
+        throw InvocationTargetException( exc.Message, *this, anyEx );
     }
 }
 
diff --git a/pyuno/source/module/pyuno_runtime.cxx b/pyuno/source/module/pyuno_runtime.cxx
index 751c104dca04..53c7acb709b8 100644
--- a/pyuno/source/module/pyuno_runtime.cxx
+++ b/pyuno/source/module/pyuno_runtime.cxx
@@ -40,6 +40,7 @@
 #include <com/sun/star/script/InvocationAdapterFactory.hpp>
 #include <com/sun/star/reflection/theCoreReflection.hpp>
 #include <comphelper/sequence.hxx>
+#include <cppuhelper/exc_hlp.hxx>
 
 #include <vector>
 
@@ -804,8 +805,9 @@ Any Runtime::pyObject2Any ( const PyRef & source, enum ConversionMode mode ) con
             }
             catch( const css::uno::Exception & e )
             {
+                css::uno::Any anyEx = cppu::getCaughtException();
                 throw WrappedTargetRuntimeException(
-                        e.Message, e.Context, makeAny(e));
+                        e.Message, e.Context, anyEx);
             }
 
         }
diff --git a/reportdesign/source/core/api/ReportDefinition.cxx b/reportdesign/source/core/api/ReportDefinition.cxx
index f738292b7e24..de391990eb12 100644
--- a/reportdesign/source/core/api/ReportDefinition.cxx
+++ b/reportdesign/source/core/api/ReportDefinition.cxx
@@ -1647,12 +1647,15 @@ void SAL_CALL OReportDefinition::load( const uno::Sequence< beans::PropertyValue
         catch (const uno::Exception&)
         {
             if ( i == nLastOpenMode )
+            {
+                css::uno::Any anyEx = cppu::getCaughtException();
                 throw lang::WrappedTargetException(
                     "An error occurred while creating the document storage.",
                         // TODO: resource
                     *this,
-                    ::cppu::getCaughtException()
+                    anyEx
                 );
+            }
         }
     }
 
diff --git a/sax/source/expatwrap/saxwriter.cxx b/sax/source/expatwrap/saxwriter.cxx
index c9d0a9b48cce..e35bb5c2b0e3 100644
--- a/sax/source/expatwrap/saxwriter.cxx
+++ b/sax/source/expatwrap/saxwriter.cxx
@@ -35,6 +35,7 @@
 
 #include <com/sun/star/io/XActiveDataSource.hpp>
 
+#include <cppuhelper/exc_hlp.hxx>
 #include <cppuhelper/weak.hxx>
 #include <cppuhelper/implbase.hxx>
 #include <cppuhelper/supportsservice.hxx>
@@ -212,14 +213,13 @@ inline sal_uInt32 SaxWriterHelper::writeSequence()
     {
         m_out->writeBytes( m_Sequence );
     }
-    catch (const IOException & e)
+    catch (const IOException &)
     {
-        Any a;
-        a <<= e;
+        css::uno::Any anyEx = cppu::getCaughtException();
         throw SAXException(
             "IO exception during writing",
             Reference< XInterface > (),
-            a );
+            anyEx );
     }
     nLastLineFeedPos -= SEQUENCESIZE;
     return 0;
@@ -1088,14 +1088,13 @@ void SAXWriter::endDocument()
     {
         m_out->closeOutput();
     }
-    catch (const IOException & e)
+    catch (const IOException &)
     {
-        Any a;
-        a <<= e;
+        css::uno::Any anyEx = cppu::getCaughtException();
         throw SAXException(
             "IO exception during closing the IO Stream",
             Reference< XInterface > (),
-            a );
+            anyEx );
     }
 }
 
diff --git a/sc/source/ui/sidebar/ScPanelFactory.cxx b/sc/source/ui/sidebar/ScPanelFactory.cxx
index fcbe9a495a42..41777caf360c 100644
--- a/sc/source/ui/sidebar/ScPanelFactory.cxx
+++ b/sc/source/ui/sidebar/ScPanelFactory.cxx
@@ -34,6 +34,7 @@
 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
 #include <com/sun/star/lang/WrappedTargetRuntimeException.hpp>
 #include <comphelper/namedvaluecollection.hxx>
+#include <cppuhelper/exc_hlp.hxx>
 #include <cppuhelper/supportsservice.hxx>
 
 using namespace css;
@@ -109,11 +110,12 @@ Reference<ui::XUIElement> SAL_CALL ScPanelFactory::createUIElement (
     {
         throw;
     }
-    catch (const uno::Exception& e)
+    catch (const uno::Exception&)
     {
+        css::uno::Any anyEx = cppu::getCaughtException();
         throw lang::WrappedTargetRuntimeException(
             "ScPanelFactory::createUIElement exception",
-            nullptr, uno::makeAny(e));
+            nullptr, anyEx);
     }
 
     return xElement;
diff --git a/sc/source/ui/unoobj/dapiuno.cxx b/sc/source/ui/unoobj/dapiuno.cxx
index 8bf22f9f4925..1bc766238ce3 100644
--- a/sc/source/ui/unoobj/dapiuno.cxx
+++ b/sc/source/ui/unoobj/dapiuno.cxx
@@ -48,6 +48,7 @@
 #include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
 #include <com/sun/star/lang/IllegalArgumentException.hpp>
 #include <com/sun/star/lang/NullPointerException.hpp>
+#include <com/sun/star/lang/WrappedTargetRuntimeException.hpp>
 #include <com/sun/star/sheet/XHierarchiesSupplier.hpp>
 #include <com/sun/star/sheet/XLevelsSupplier.hpp>
 #include <com/sun/star/sheet/XMembersSupplier.hpp>
@@ -63,6 +64,7 @@
 #include <comphelper/propertysequence.hxx>
 #include <comphelper/sequence.hxx>
 #include <comphelper/servicehelper.hxx>
+#include <cppuhelper/exc_hlp.hxx>
 
 using namespace com::sun::star;
 using namespace com::sun::star::sheet;
@@ -2664,9 +2666,12 @@ Reference< XDataPilotField > SAL_CALL ScDataPilotFieldObj::createNameGroup( cons
             }
             catch (const container::NoSuchElementException&)
             {
+                css::uno::Any anyEx = cppu::getCaughtException();
                 SAL_WARN("sc.ui", "Cannot find field with that name: " + sNewDim + ".");
                 // Avoid throwing exception that's not specified in the method signature.
-                throw RuntimeException("Cannot find field with name \"" + sNewDim + "\"", static_cast<cppu::OWeakObject*>(this));
+                throw css::lang::WrappedTargetRuntimeException(
+                        "Cannot find field with name \"" + sNewDim + "\"",
+                        static_cast<cppu::OWeakObject*>(this), anyEx );
             }
         }
     }
diff --git a/sc/source/ui/vba/vbaaxes.cxx b/sc/source/ui/vba/vbaaxes.cxx
index babb55e034b3..1f1ee3b2a9de 100644
--- a/sc/source/ui/vba/vbaaxes.cxx
+++ b/sc/source/ui/vba/vbaaxes.cxx
@@ -21,6 +21,7 @@
 #include "vbaaxis.hxx"
 #include "vbachart.hxx"
 #include <basic/sberrors.hxx>
+#include <cppuhelper/exc_hlp.hxx>
 #include <cppuhelper/implbase.hxx>
 #include <ooo/vba/excel/XlAxisType.hpp>
 #include <ooo/vba/excel/XlAxisGroup.hpp>
@@ -124,12 +125,13 @@ public:
             AxesCoordinate dIndexes = mCoordinates[ Index ];
             return uno::makeAny( ScVbaAxes::createAxis( mxChart, mxContext, dIndexes.second, dIndexes.first ) );
         }
-        catch (const css::script::BasicErrorException& e)
+        catch (const css::script::BasicErrorException&)
         {
+            css::uno::Any anyEx = cppu::getCaughtException();
             throw css::lang::WrappedTargetException(
                    "Error Getting Index!",
                    static_cast < OWeakObject * > ( this ),
-                   makeAny( e ) );
+                   anyEx );
         }
     }
     // XElementAccess
diff --git a/sc/source/ui/vba/vbachartobjects.cxx b/sc/source/ui/vba/vbachartobjects.cxx
index 3b427d4228b4..beb97e5b0ea6 100644
--- a/sc/source/ui/vba/vbachartobjects.cxx
+++ b/sc/source/ui/vba/vbachartobjects.cxx
@@ -65,12 +65,13 @@ public:
         {
             throw;
         }
-        catch (const uno::Exception& e)
+        catch (const uno::Exception&)
         {
+            css::uno::Any anyEx(cppu::getCaughtException());
             throw lang::WrappedTargetException(
                     "Error creating ScVbaChartObject!",
                     static_cast < OWeakObject * > ( this ),
-                    makeAny( e ) );
+                    anyEx );
         }
         return ret;
     }
diff --git a/sc/source/ui/vba/vbarange.cxx b/sc/source/ui/vba/vbarange.cxx
index 2ad45a3716a8..9d2b78693fee 100644
--- a/sc/source/ui/vba/vbarange.cxx
+++ b/sc/source/ui/vba/vbarange.cxx
@@ -22,6 +22,7 @@
 #include <vbahelper/helperdecl.hxx>
 
 #include <comphelper/unwrapargs.hxx>
+#include <cppuhelper/exc_hlp.hxx>
 #include <o3tl/any.hxx>
 #include <sfx2/objsh.hxx>
 
@@ -61,6 +62,7 @@
 #include <com/sun/star/table/TableSortField.hpp>
 #include <com/sun/star/util/XMergeable.hpp>
 #include <com/sun/star/uno/XComponentContext.hpp>
+#include <com/sun/star/lang/WrappedTargetRuntimeException.hpp>
 #include <com/sun/star/lang/XMultiComponentFactory.hpp>
 #include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
 #include <com/sun/star/util/XNumberFormatsSupplier.hpp>
@@ -2981,7 +2983,9 @@ ScVbaRange::getHidden()
     }
     catch( const uno::Exception& e )
     {
-        throw uno::RuntimeException( e.Message );
+        css::uno::Any anyEx = cppu::getCaughtException();
+        throw css::lang::WrappedTargetRuntimeException( e.Message,
+                        nullptr, anyEx );
     }
     return uno::makeAny( !bIsVisible );
 }
@@ -3008,7 +3012,9 @@ ScVbaRange::setHidden( const uno::Any& _hidden )
     }
     catch( const uno::Exception& e )
     {
-        throw uno::RuntimeException( e.Message );
+        css::uno::Any anyEx = cppu::getCaughtException();
+        throw css::lang::WrappedTargetRuntimeException( e.Message,
+                        nullptr, anyEx );
     }
 }
 
diff --git a/scripting/source/protocolhandler/scripthandler.cxx b/scripting/source/protocolhandler/scripthandler.cxx
index d238bdbd300d..2933ab8b7f0d 100644
--- a/scripting/source/protocolhandler/scripthandler.cxx
+++ b/scripting/source/protocolhandler/scripthandler.cxx
@@ -27,6 +27,7 @@
 #include <com/sun/star/document/XEmbeddedScripts.hpp>
 #include <com/sun/star/document/XScriptInvocationContext.hpp>
 
+#include <com/sun/star/lang/WrappedTargetRuntimeException.hpp>
 #include <com/sun/star/lang/XSingleServiceFactory.hpp>
 #include <com/sun/star/script/provider/ScriptFrameworkErrorException.hpp>
 #include <com/sun/star/script/provider/XScriptProviderSupplier.hpp>
@@ -399,15 +400,12 @@ void ScriptProtocolHandler::createScriptProvider()
             m_xScriptProvider.set( xFac->createScriptProvider( aContext ), UNO_QUERY_THROW );
         }
     }
-    catch ( const RuntimeException & e )
-    {
-        OUString temp = "ScriptProtocolHandler::createScriptProvider(),  ";
-        throw RuntimeException( temp.concat( e.Message ) );
-    }
     catch ( const Exception & e )
     {
-        OUString temp = "ScriptProtocolHandler::createScriptProvider: ";
-        throw RuntimeException( temp.concat( e.Message ) );
+        css::uno::Any anyEx = cppu::getCaughtException();
+        throw css::lang::WrappedTargetRuntimeException(
+            "ScriptProtocolHandler::createScriptProvider: " + e.Message,
+            nullptr, anyEx );
     }
 }
 
diff --git a/scripting/source/provider/ActiveMSPList.cxx b/scripting/source/provider/ActiveMSPList.cxx
index 6b1da6093352..5411b5a474ef 100644
--- a/scripting/source/provider/ActiveMSPList.cxx
+++ b/scripting/source/provider/ActiveMSPList.cxx
@@ -218,10 +218,11 @@ Reference< provider::XScriptProvider >
     }
     catch( const Exception& )
     {
+        css::uno::Any anyEx = cppu::getCaughtException();
         throw lang::WrappedTargetRuntimeException(
             "Failed to create MasterScriptProvider for context '"
             + context + "'.",
-            *this, ::cppu::getCaughtException() );
+            *this, anyEx );
     }
     return msp;
 }
diff --git a/scripting/source/provider/ProviderCache.cxx b/scripting/source/provider/ProviderCache.cxx
index 98103a8984e3..09cfbcb6c988 100644
--- a/scripting/source/provider/ProviderCache.cxx
+++ b/scripting/source/provider/ProviderCache.cxx
@@ -22,6 +22,7 @@
 #include <tools/diagnose_ex.h>
 
 #include <com/sun/star/container/XContentEnumerationAccess.hpp>
+#include <com/sun/star/lang/WrappedTargetRuntimeException.hpp>
 #include "ProviderCache.hxx"
 
 using namespace com::sun::star;
@@ -168,10 +169,11 @@ ProviderCache::populateCache()
     }
     catch ( const Exception &e )
     {
-        OUString temp =
-            "ProviderCache::populateCache: couldn't obtain XSingleComponentFactory for "
-            + serviceName;
-        throw RuntimeException( temp.concat( e.Message ) );
+        css::uno::Any anyEx = cppu::getCaughtException();
+        throw css::lang::WrappedTargetRuntimeException(
+                "ProviderCache::populateCache: couldn't obtain XSingleComponentFactory for " + serviceName
+                + " " + e.Message,
+                nullptr, anyEx );
     }
 }
 
@@ -185,7 +187,10 @@ ProviderCache::createProvider( ProviderDetails& details )
     }
     catch ( const Exception& e )
     {
-        throw RuntimeException( "ProviderCache::createProvider() Error creating provider from factory. " + e.Message );
+        css::uno::Any anyEx = cppu::getCaughtException();
+        throw css::lang::WrappedTargetRuntimeException(
+                "ProviderCache::createProvider() Error creating provider from factory. " + e.Message,
+                nullptr, anyEx );
     }
 
     return details.provider;
diff --git a/sd/source/core/stlsheet.cxx b/sd/source/core/stlsheet.cxx
index 3327304a0d3d..4f2cde188768 100644
--- a/sd/source/core/stlsheet.cxx
+++ b/sd/source/core/stlsheet.cxx
@@ -19,10 +19,12 @@
 
 #include <com/sun/star/beans/PropertyAttribute.hpp>
 #include <com/sun/star/lang/DisposedException.hpp>
+#include <com/sun/star/lang/WrappedTargetRuntimeException.hpp>
 #include <com/sun/star/style/XStyle.hpp>
 
 #include <osl/mutex.hxx>
 #include <vcl/svapp.hxx>
+#include <cppuhelper/exc_hlp.hxx>
 #include <cppuhelper/supportsservice.hxx>
 #include <cppuhelper/interfacecontainer.hxx>
 
@@ -723,7 +725,10 @@ void SAL_CALL SdStyleSheet::dispose(  )
         }
         catch (const Exception & exc)
         {
-            throw RuntimeException( "unexpected UNO exception caught: " + exc.Message );
+            css::uno::Any anyEx = cppu::getCaughtException();
+            throw css::lang::WrappedTargetRuntimeException(
+                "unexpected UNO exception caught: " + exc.Message ,
+                nullptr, anyEx );
         }
     }
 }
diff --git a/sfx2/source/doc/DocumentMetadataAccess.cxx b/sfx2/source/doc/DocumentMetadataAccess.cxx
index ff6ad06ea6a7..b24edf6e184c 100644
--- a/sfx2/source/doc/DocumentMetadataAccess.cxx
+++ b/sfx2/source/doc/DocumentMetadataAccess.cxx
@@ -44,6 +44,7 @@
 #include <unotools/mediadescriptor.hxx>
 #include <comphelper/sequence.hxx>
 #include <comphelper/storagehelper.hxx>
+#include <cppuhelper/exc_hlp.hxx>
 
 #include <sfx2/docfile.hxx>
 #include <sfx2/XmlIdRegistry.hxx>
@@ -305,9 +306,10 @@ addFile(struct DocumentMetadataAccess_Impl const & i_rImpl,
         }
     } catch (const uno::RuntimeException &) {
         throw;
-    } catch (const uno::Exception & e) {
+    } catch (const uno::Exception &) {
+        css::uno::Any anyEx = cppu::getCaughtException();
         throw lang::WrappedTargetRuntimeException(
-            "addFile: exception", /*this*/nullptr, uno::makeAny(e));
+            "addFile: exception", /*this*/nullptr, anyEx);
     }
 }
 
@@ -353,10 +355,11 @@ removeFile(struct DocumentMetadataAccess_Impl const & i_rImpl,
             getURI<rdf::URIs::RDF_TYPE>(i_rImpl.m_xContext), nullptr);
     } catch (const uno::RuntimeException &) {
         throw;
-    } catch (const uno::Exception & e) {

... etc. - the rest is truncated


More information about the Libreoffice-commits mailing list