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
diff --git a/comphelper/source/misc/officerestartmanager.cxx b/comphelper/source/misc/officerestartmanager.cxx
index 86eb18f..81e9b33 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 e0b389c..30201b9 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 3508f93..264feae 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 2bfcca9..e2c92e2 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 ed7d293..dd47dd2 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 e0d312a..2568385 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 90b27c2..68afc32 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() );