Kaydet (Commit) 3a51daea authored tarafından Noel Grandin's avatar Noel Grandin

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/54692Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst ff3bdde2
......@@ -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 );
}
}
......
......@@ -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);
}
}
}
......
......@@ -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;
......
......@@ -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;
......
......@@ -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);
}
}
}
......
......@@ -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)
......
......@@ -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 );
......
......@@ -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;
......
......@@ -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;
......
......@@ -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 );
}
}
}
......
......@@ -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!" );
......
......@@ -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& )
{
......
......@@ -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 );
}
}
......
......@@ -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 ) );
}
......
......@@ -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 ) );
......
......@@ -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 ) );
......
......@@ -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 ) );
......
......@@ -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 ) );
......
......@@ -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 ) );
......
......@@ -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 ) );
......
......@@ -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 ) );
}
......
......@@ -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);
}
......
......@@ -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
......
......@@ -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 );
}
}
}
......
......@@ -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(