diff options
author | RMZeroFour <ritobroto04@gmail.com> | 2024-03-24 23:00:34 +0530 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2024-03-30 13:32:16 +0100 |
commit | 599b113b732190749385293a9fbc8ffc3e618556 (patch) | |
tree | 4b8a067f5ba09b97a2fda6cf434fb86fa652307b | |
parent | 13250e1aa589453534d113442da1ac8a2cbb71b9 (diff) |
tdf#42982 Add error messages to thrown exceptions
As part of the efforts in #42982 to improve the UNO API
error reporting, this commit adds error messages in several
files to help improve debugging experience.
Change-Id: I7a51d4fd1e3a57798d70bc3464b034649948a287
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165253
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Tested-by: Jenkins
-rw-r--r-- | comphelper/source/misc/officerestartmanager.cxx | 2 | ||||
-rw-r--r-- | comphelper/source/property/opropertybag.cxx | 2 | ||||
-rw-r--r-- | comphelper/source/streaming/seekableinput.cxx | 5 | ||||
-rw-r--r-- | forms/source/component/propertybaghelper.cxx | 2 | ||||
-rw-r--r-- | forms/source/helper/windowstateguard.cxx | 8 | ||||
-rw-r--r-- | forms/source/xforms/submission.cxx | 2 | ||||
-rw-r--r-- | svl/source/passwordcontainer/passwordcontainer.cxx | 8 |
7 files changed, 17 insertions, 12 deletions
diff --git a/comphelper/source/misc/officerestartmanager.cxx b/comphelper/source/misc/officerestartmanager.cxx index 86eb18f623c9..81e9b3351d7e 100644 --- a/comphelper/source/misc/officerestartmanager.cxx +++ b/comphelper/source/misc/officerestartmanager.cxx @@ -36,7 +36,7 @@ namespace comphelper void SAL_CALL OOfficeRestartManager::requestRestart( const uno::Reference< task::XInteractionHandler >& /* xInteractionHandler */ ) { if ( !m_xContext.is() ) - throw uno::RuntimeException(); + throw uno::RuntimeException("no component context"); { std::unique_lock aGuard( m_aMutex ); diff --git a/comphelper/source/property/opropertybag.cxx b/comphelper/source/property/opropertybag.cxx index e0b389c19199..30201b9ff772 100644 --- a/comphelper/source/property/opropertybag.cxx +++ b/comphelper/source/property/opropertybag.cxx @@ -389,7 +389,7 @@ namespace comphelper { aValues = OPropertyBag_PBase::getPropertyValues( aNames ); if ( aValues.getLength() != aNames.getLength() ) - throw RuntimeException(); + throw RuntimeException("property name and value counts out of sync"); } catch( const RuntimeException& ) { diff --git a/comphelper/source/streaming/seekableinput.cxx b/comphelper/source/streaming/seekableinput.cxx index 3508f933ee26..264feaeb3071 100644 --- a/comphelper/source/streaming/seekableinput.cxx +++ b/comphelper/source/streaming/seekableinput.cxx @@ -24,6 +24,7 @@ #include <com/sun/star/io/TempFile.hpp> #include <com/sun/star/io/XOutputStream.hpp> +#include <com/sun/star/lang/IllegalArgumentException.hpp> #include <comphelper/seekableinput.hxx> #include <utility> @@ -64,7 +65,7 @@ OSeekableInputWrapper::OSeekableInputWrapper( , m_xOriginalStream(std::move( xInStream )) { if ( !m_xContext.is() ) - throw uno::RuntimeException(); + throw lang::IllegalArgumentException("no component context", *this, 1); } @@ -91,7 +92,7 @@ void OSeekableInputWrapper::PrepareCopy_Impl() if ( !m_xCopyInput.is() ) { if ( !m_xContext.is() ) - throw uno::RuntimeException(); + throw uno::RuntimeException("no component context"); uno::Reference< io::XOutputStream > xTempOut( io::TempFile::create(m_xContext), diff --git a/forms/source/component/propertybaghelper.cxx b/forms/source/component/propertybaghelper.cxx index 2bfcca91a320..e2c92e24c008 100644 --- a/forms/source/component/propertybaghelper.cxx +++ b/forms/source/component/propertybaghelper.cxx @@ -267,7 +267,7 @@ namespace frm aValues = xMe->getPropertyValues( aPropertyNames ); if ( aValues.getLength() != aPropertyNames.getLength() ) - throw RuntimeException(); + throw RuntimeException("property name and value counts out of sync"); } catch( const RuntimeException& ) { throw; } catch( const Exception& ) diff --git a/forms/source/helper/windowstateguard.cxx b/forms/source/helper/windowstateguard.cxx index ed7d2932abb9..dd47dd2989b9 100644 --- a/forms/source/helper/windowstateguard.cxx +++ b/forms/source/helper/windowstateguard.cxx @@ -20,6 +20,7 @@ #include <windowstateguard.hxx> #include <frm_strings.hxx> +#include <com/sun/star/lang/IllegalArgumentException.hpp> #include <com/sun/star/awt/XWindowListener2.hpp> #include <com/sun/star/beans/XPropertySet.hpp> #include <cppuhelper/implbase.hxx> @@ -35,6 +36,7 @@ namespace frm using ::com::sun::star::awt::XWindow2; using ::com::sun::star::awt::WindowEvent; using ::com::sun::star::uno::RuntimeException; + using ::com::sun::star::lang::IllegalArgumentException; using ::com::sun::star::awt::XControlModel; using ::com::sun::star::beans::XPropertySet; using ::com::sun::star::lang::EventObject; @@ -88,8 +90,10 @@ namespace frm :m_xWindow( _rxWindow ) ,m_xModelProps( _rxMdelProps ) { - if ( !m_xWindow.is() || !m_xModelProps.is() ) - throw RuntimeException(); + if ( !m_xWindow.is() ) + throw IllegalArgumentException("no window supplied", *this, 0); + if ( !m_xModelProps.is() ) + throw IllegalArgumentException("no property set supplied", *this, 1); osl_atomic_increment( &m_refCount ); { diff --git a/forms/source/xforms/submission.cxx b/forms/source/xforms/submission.cxx index e0d312aa63f0..256838558f6e 100644 --- a/forms/source/xforms/submission.cxx +++ b/forms/source/xforms/submission.cxx @@ -285,7 +285,7 @@ void Submission::liveCheck() bool bValid = mxModel.is(); if( ! bValid ) - throw RuntimeException(); + throw RuntimeException("model not set"); } css::uno::Reference<XModel> Submission::getModel() const diff --git a/svl/source/passwordcontainer/passwordcontainer.cxx b/svl/source/passwordcontainer/passwordcontainer.cxx index 90b27c29f7b0..68afc328935d 100644 --- a/svl/source/passwordcontainer/passwordcontainer.cxx +++ b/svl/source/passwordcontainer/passwordcontainer.cxx @@ -1222,7 +1222,7 @@ sal_Bool SAL_CALL PasswordContainer::hasMasterPassword( ) std::unique_lock aGuard( mMutex ); if ( !m_xStorageFile ) - throw uno::RuntimeException(); + throw uno::RuntimeException("storage file not set"); OUString aEncodedMP, aEncodedMPIV; return ( m_xStorageFile->useStorage() && m_xStorageFile->getEncodedMasterPassword( aEncodedMP, aEncodedMPIV ) ); @@ -1233,7 +1233,7 @@ sal_Bool SAL_CALL PasswordContainer::allowPersistentStoring( sal_Bool bAllow ) std::unique_lock aGuard( mMutex ); if ( !m_xStorageFile ) - throw uno::RuntimeException(); + throw uno::RuntimeException("storage file not set"); if ( !bAllow ) removeMasterPassword(aGuard); @@ -1250,7 +1250,7 @@ sal_Bool SAL_CALL PasswordContainer::isPersistentStoringAllowed() std::unique_lock aGuard( mMutex ); if ( !m_xStorageFile ) - throw uno::RuntimeException(); + throw uno::RuntimeException("storage file not set"); return m_xStorageFile->useStorage(); } @@ -1312,7 +1312,7 @@ sal_Bool SAL_CALL PasswordContainer::isDefaultMasterPasswordUsed() std::unique_lock aGuard( mMutex ); if ( !m_xStorageFile ) - throw uno::RuntimeException(); + throw uno::RuntimeException("storage file not set"); OUString aEncodedMP, aEncodedMPIV; return ( m_xStorageFile->useStorage() && m_xStorageFile->getEncodedMasterPassword( aEncodedMP, aEncodedMPIV ) && aEncodedMP.isEmpty() ); |