From 2bcefa7aab176bf18b45e7038e91dd07ced6edf7 Mon Sep 17 00:00:00 2001 From: Saurav Sachidanand Date: Tue, 17 Jan 2017 22:16:28 +0530 Subject: tdf#42982 Make UNO error reporting more descriptive Change-Id: I0fae43ca1ab23f35e75fd6b88215940596aae09f Reviewed-on: https://gerrit.libreoffice.org/33227 Tested-by: Jenkins Reviewed-by: Stephan Bergmann --- basic/source/uno/dlgcont.cxx | 8 ++++---- basic/source/uno/namecont.cxx | 20 ++++++++------------ basic/source/uno/scriptcont.cxx | 22 +++++++++++----------- 3 files changed, 23 insertions(+), 27 deletions(-) diff --git a/basic/source/uno/dlgcont.cxx b/basic/source/uno/dlgcont.cxx index a1a1f05f57b4..4bc038033534 100644 --- a/basic/source/uno/dlgcont.cxx +++ b/basic/source/uno/dlgcont.cxx @@ -369,12 +369,12 @@ Reference< css::resource::XStringResourcePersistence > xLibrariesStor = mxStorage->openStorageElement( maLibrariesDir, embed::ElementModes::READ ); // TODO: Should be READWRITE with new storage concept using store() instead of storeTo() if ( !xLibrariesStor.is() ) - throw uno::RuntimeException(); + throw uno::RuntimeException("null returned from openStorageElement"); xLibraryStor = xLibrariesStor->openStorageElement( aLibName, embed::ElementModes::READ ); // TODO: Should be READWRITE with new storage concept using store() instead of storeTo() if ( !xLibraryStor.is() ) - throw uno::RuntimeException(); + throw uno::RuntimeException("null returned from openStorageElement"); } catch(const uno::Exception& ) { @@ -422,12 +422,12 @@ void SfxDialogLibraryContainer::onNewRootStorage() try { xLibrariesStor = mxStorage->openStorageElement( maLibrariesDir, embed::ElementModes::READWRITE ); if ( !xLibrariesStor.is() ) - throw uno::RuntimeException(); + throw uno::RuntimeException("null returned from openStorageElement"); OUString aLibName = pDialogLibrary->getName(); xLibraryStor = xLibrariesStor->openStorageElement( aLibName, embed::ElementModes::READWRITE ); if ( !xLibraryStor.is() ) - throw uno::RuntimeException(); + throw uno::RuntimeException("null returned from openStorageElement"); Reference< resource::XStringResourceWithStorage > xStringResourceWithStorage( xStringResourcePersistence, UNO_QUERY ); diff --git a/basic/source/uno/namecont.cxx b/basic/source/uno/namecont.cxx index 4cf0c9db70ac..ae83e5a939f1 100644 --- a/basic/source/uno/namecont.cxx +++ b/basic/source/uno/namecont.cxx @@ -293,8 +293,7 @@ void SAL_CALL NameContainer::addContainerListener( const Reference< XContainerLi { if( !xListener.is() ) { - throw RuntimeException("addContainerListener called with null xListener", - static_cast< cppu::OWeakObject * >(this)); + throw RuntimeException("addContainerListener called with null xListener"); } maContainerListeners.addInterface( Reference(xListener, UNO_QUERY) ); } @@ -303,8 +302,7 @@ void SAL_CALL NameContainer::removeContainerListener( const Reference< XContaine { if( !xListener.is() ) { - throw RuntimeException("removeContainerListener called with null xListener", - static_cast< cppu::OWeakObject * >(this)); + throw RuntimeException("removeContainerListener called with null xListener"); } maContainerListeners.removeInterface( Reference(xListener, UNO_QUERY) ); } @@ -314,8 +312,7 @@ void SAL_CALL NameContainer::addChangesListener( const Reference< XChangesListen { if( !xListener.is() ) { - throw RuntimeException("addChangesListener called with null xListener", - static_cast< cppu::OWeakObject * >(this)); + throw RuntimeException("addChangesListener called with null xListener"); } maChangesListeners.addInterface( Reference(xListener, UNO_QUERY) ); } @@ -324,8 +321,7 @@ void SAL_CALL NameContainer::removeChangesListener( const Reference< XChangesLis { if( !xListener.is() ) { - throw RuntimeException("removeChangesListener called with null xListener", - static_cast< cppu::OWeakObject * >(this)); + throw RuntimeException("removeChangesListener called with null xListener"); } maChangesListeners.removeInterface( Reference(xListener, UNO_QUERY) ); } @@ -2086,7 +2082,7 @@ void SfxLibraryContainer::storeLibraries_Impl( const uno::Reference< embed::XSto "The stream must implement XPropertySet!"); if ( !xProps.is() ) { - throw uno::RuntimeException(); + throw uno::RuntimeException("InfoStream doesn't implement XPropertySet"); } OUString aMime( "text/xml" ); xProps->setPropertyValue("MediaType", uno::Any( aMime ) ); @@ -2144,7 +2140,7 @@ void SfxLibraryContainer::storeLibraries_Impl( const uno::Reference< embed::XSto "The storage must implement XTransactedObject!"); if ( !xTransact.is() ) { - throw uno::RuntimeException(); + throw uno::RuntimeException("xTargetLibrariesStor doesn't implement XTransactedObject"); } xTransact->commit(); } @@ -2370,7 +2366,7 @@ void SAL_CALL SfxLibraryContainer::loadLibrary( const OUString& Name ) " storage!")); if ( !xLibrariesStor.is() ) { - throw uno::RuntimeException(); + throw uno::RuntimeException("null returned from openStorageElement"); } xLibraryStor = xLibrariesStor->openStorageElement( Name, embed::ElementModes::READ ); @@ -2380,7 +2376,7 @@ void SAL_CALL SfxLibraryContainer::loadLibrary( const OUString& Name ) " storage!")); if ( !xLibrariesStor.is() ) { - throw uno::RuntimeException(); + throw uno::RuntimeException("null returned from openStorageElement"); } } catch(const uno::Exception& ) diff --git a/basic/source/uno/scriptcont.cxx b/basic/source/uno/scriptcont.cxx index 02d76acf5f6c..cfd744708f5b 100644 --- a/basic/source/uno/scriptcont.cxx +++ b/basic/source/uno/scriptcont.cxx @@ -624,7 +624,7 @@ bool SfxScriptLibraryContainer::implStorePasswordLibrary( SfxLibrary* pLib, cons if ( !xCodeStream.is() ) { - throw uno::RuntimeException(); + throw uno::RuntimeException("null returned from openStreamElement"); } SvMemoryStream aMemStream; /*sal_Bool bStore = */pMod->StoreBinaryData( aMemStream, B_CURVERSION ); @@ -671,7 +671,7 @@ bool SfxScriptLibraryContainer::implStorePasswordLibrary( SfxLibrary* pLib, cons uno::Reference< beans::XPropertySet > xProps( xSourceStream, uno::UNO_QUERY ); if ( !xProps.is() ) { - throw uno::RuntimeException(); + throw uno::RuntimeException("xSourceStream doesn't implement XPropertySet"); } OUString aMime( "text/xml" ); xProps->setPropertyValue("MediaType", uno::Any( aMime ) ); @@ -756,7 +756,7 @@ bool SfxScriptLibraryContainer::implStorePasswordLibrary( SfxLibrary* pLib, cons embed::ElementModes::READWRITE ); if ( !xElementRootStorage.is() ) { - throw uno::RuntimeException(); + throw uno::RuntimeException("null returned from GetStorageFromURL"); } // Write binary image stream SbModule* pMod = pBasicLib->FindModule( aElementName ); @@ -801,7 +801,7 @@ bool SfxScriptLibraryContainer::implStorePasswordLibrary( SfxLibrary* pLib, cons "StorageStream opened for writing must implement XEncryptionProtectedSource!\n" ); if ( !xEncr.is() ) { - throw uno::RuntimeException(); + throw uno::RuntimeException("xSourceStream doesn't implement XEncryptionProtectedSource"); } xEncr->setEncryptionPassword( pLib->maPassword ); } @@ -816,7 +816,7 @@ bool SfxScriptLibraryContainer::implStorePasswordLibrary( SfxLibrary* pLib, cons uno::Reference< beans::XPropertySet > xProps( xSourceStream, uno::UNO_QUERY ); if ( !xProps.is() ) { - throw uno::RuntimeException(); + throw uno::RuntimeException("xSourceStream doesn't implement XPropertySet"); } OUString aMime( "text/xml" ); xProps->setPropertyValue("MediaType", uno::Any( aMime ) ); @@ -831,7 +831,7 @@ bool SfxScriptLibraryContainer::implStorePasswordLibrary( SfxLibrary* pLib, cons OSL_ENSURE( xTransact.is(), "The storage must implement XTransactedObject!\n" ); if ( !xTransact.is() ) { - throw uno::RuntimeException(); + throw uno::RuntimeException("xElementRootStorage doesn't implement XTransactedObject"); } xTransact->commit(); @@ -908,12 +908,12 @@ bool SfxScriptLibraryContainer::implLoadPasswordLibrary xLibrariesStor = mxStorage->openStorageElement( maLibrariesDir, embed::ElementModes::READ ); if ( !xLibrariesStor.is() ) { - throw uno::RuntimeException(); + throw uno::RuntimeException("null returned from openStorageElement"); } xLibraryStor = xLibrariesStor->openStorageElement( Name, embed::ElementModes::READ ); if ( !xLibraryStor.is() ) { - throw uno::RuntimeException(); + throw uno::RuntimeException("null returned from openStorageElement"); } } catch(const uno::Exception& ) @@ -945,7 +945,7 @@ bool SfxScriptLibraryContainer::implLoadPasswordLibrary embed::ElementModes::READ ); if ( !xCodeStream.is() ) { - throw uno::RuntimeException(); + throw uno::RuntimeException("null returned from openStreamElement"); } std::unique_ptr pStream(::utl::UcbStreamHelper::CreateStream( xCodeStream )); if ( !pStream || pStream->GetError() ) @@ -980,7 +980,7 @@ bool SfxScriptLibraryContainer::implLoadPasswordLibrary pLib->maPassword ); if ( !xSourceStream.is() ) { - throw uno::RuntimeException(); + throw uno::RuntimeException("null returned from openEncryptedStreamElement"); } // if this point is reached then the password is correct if ( !bVerifyPasswordOnly ) @@ -1094,7 +1094,7 @@ bool SfxScriptLibraryContainer::implLoadPasswordLibrary pLib->maPassword ); if ( !xSourceStream.is() ) { - throw uno::RuntimeException(); + throw uno::RuntimeException("null returned from openEncryptedStreamElement"); } if ( !bVerifyPasswordOnly ) { -- cgit v1.2.3