diff options
author | Noel <noel.grandin@collabora.co.uk> | 2021-01-18 15:05:18 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-01-20 09:03:45 +0100 |
commit | bca1b74c0753f2305a5e234293df88aa3e1d9af0 (patch) | |
tree | 16732572c6e15dbd5a2f4e50a2451efc836e3a2d /comphelper | |
parent | 35a564864e6ce08abfa4924e1ea9314982e7957c (diff) |
improve some IllegalArgumentException messages
Change-Id: Id88f2a82bf2651e8b5895aa330f32b71ff5b0e48
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109546
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'comphelper')
-rw-r--r-- | comphelper/source/container/IndexedPropertyValuesContainer.cxx | 4 | ||||
-rw-r--r-- | comphelper/source/container/NamedPropertyValuesContainer.cxx | 4 | ||||
-rw-r--r-- | comphelper/source/container/enumerablemap.cxx | 2 | ||||
-rw-r--r-- | comphelper/source/container/namecontainer.cxx | 4 | ||||
-rw-r--r-- | comphelper/source/eventattachermgr/eventattachermgr.cxx | 8 | ||||
-rw-r--r-- | comphelper/source/misc/anycompare.cxx | 6 | ||||
-rw-r--r-- | comphelper/source/misc/types.cxx | 3 | ||||
-rw-r--r-- | comphelper/source/property/ChainablePropertySet.cxx | 2 | ||||
-rw-r--r-- | comphelper/source/property/opropertybag.cxx | 4 | ||||
-rw-r--r-- | comphelper/source/property/propertysethelper.cxx | 2 | ||||
-rw-r--r-- | comphelper/source/streaming/seqstream.cxx | 2 |
11 files changed, 21 insertions, 20 deletions
diff --git a/comphelper/source/container/IndexedPropertyValuesContainer.cxx b/comphelper/source/container/IndexedPropertyValuesContainer.cxx index fe4ba0cff91a..639fb625797e 100644 --- a/comphelper/source/container/IndexedPropertyValuesContainer.cxx +++ b/comphelper/source/container/IndexedPropertyValuesContainer.cxx @@ -80,7 +80,7 @@ void SAL_CALL IndexedPropertyValuesContainer::insertByIndex( sal_Int32 nIndex, c uno::Sequence<beans::PropertyValue> aProps; if (!(aElement >>= aProps)) - throw lang::IllegalArgumentException(); + throw lang::IllegalArgumentException("element is not beans::PropertyValue", static_cast<cppu::OWeakObject*>(this), 2); if (nSize == nIndex) maProperties.push_back(aProps); else @@ -104,7 +104,7 @@ void SAL_CALL IndexedPropertyValuesContainer::replaceByIndex( sal_Int32 nIndex, uno::Sequence<beans::PropertyValue> aProps; if (!(aElement >>= aProps)) - throw lang::IllegalArgumentException(); + throw lang::IllegalArgumentException("element is not beans::PropertyValue", static_cast<cppu::OWeakObject*>(this), 2); maProperties[nIndex] = aProps; } diff --git a/comphelper/source/container/NamedPropertyValuesContainer.cxx b/comphelper/source/container/NamedPropertyValuesContainer.cxx index 79a7d714b5e6..dbd0e422b5fb 100644 --- a/comphelper/source/container/NamedPropertyValuesContainer.cxx +++ b/comphelper/source/container/NamedPropertyValuesContainer.cxx @@ -78,7 +78,7 @@ void SAL_CALL NamedPropertyValuesContainer::insertByName( const OUString& aName, uno::Sequence<beans::PropertyValue> aProps; if( !(aElement >>= aProps ) ) - throw lang::IllegalArgumentException(); + throw lang::IllegalArgumentException("element is not beans::PropertyValue", static_cast<cppu::OWeakObject*>(this), 2); maProperties.emplace( aName, aProps ); } @@ -101,7 +101,7 @@ void SAL_CALL NamedPropertyValuesContainer::replaceByName( const OUString& aName uno::Sequence<beans::PropertyValue> aProps; if( !(aElement >>= aProps) ) - throw lang::IllegalArgumentException(); + throw lang::IllegalArgumentException("element is not beans::PropertyValue", static_cast<cppu::OWeakObject*>(this), 2); (*aIter).second = aProps; } diff --git a/comphelper/source/container/enumerablemap.cxx b/comphelper/source/container/enumerablemap.cxx index 1730d2dc2668..ae6053d7520c 100644 --- a/comphelper/source/container/enumerablemap.cxx +++ b/comphelper/source/container/enumerablemap.cxx @@ -326,7 +326,7 @@ namespace comphelper sal_Int32 nArgumentCount = _arguments.getLength(); if ( ( nArgumentCount != 2 ) && ( nArgumentCount != 3 ) ) - throw IllegalArgumentException(); + throw IllegalArgumentException("wrong number of args", static_cast<cppu::OWeakObject*>(this), 1); Type aKeyType, aValueType; if ( !( _arguments[0] >>= aKeyType ) ) diff --git a/comphelper/source/container/namecontainer.cxx b/comphelper/source/container/namecontainer.cxx index bed257ca50c7..fc43d871d7e4 100644 --- a/comphelper/source/container/namecontainer.cxx +++ b/comphelper/source/container/namecontainer.cxx @@ -85,7 +85,7 @@ void SAL_CALL NameContainer::insertByName( const OUString& aName, const Any& aEl throw ElementExistException(); if( aElement.getValueType() != maType ) - throw IllegalArgumentException(); + throw IllegalArgumentException("element is wrong type", static_cast<cppu::OWeakObject*>(this), 2); maProperties.emplace(aName,aElement); } @@ -112,7 +112,7 @@ void SAL_CALL NameContainer::replaceByName( const OUString& aName, const Any& aE throw NoSuchElementException(); if( aElement.getValueType() != maType ) - throw IllegalArgumentException(); + throw IllegalArgumentException("element is wrong type", static_cast<cppu::OWeakObject*>(this), 2); (*aIter).second = aElement; } diff --git a/comphelper/source/eventattachermgr/eventattachermgr.cxx b/comphelper/source/eventattachermgr/eventattachermgr.cxx index e92b7fc70e1a..4a36c0f1192f 100644 --- a/comphelper/source/eventattachermgr/eventattachermgr.cxx +++ b/comphelper/source/eventattachermgr/eventattachermgr.cxx @@ -379,7 +379,7 @@ Reference< XIdlReflection > ImplEventAttacherManager::getReflection() std::deque< AttacherIndex_Impl >::iterator ImplEventAttacherManager::implCheckIndex( sal_Int32 _nIndex ) { if ( (_nIndex < 0) || (o3tl::make_unsigned(_nIndex) >= aIndex.size()) ) - throw IllegalArgumentException(); + throw IllegalArgumentException("wrong index", static_cast<cppu::OWeakObject*>(this), 1); std::deque<AttacherIndex_Impl>::iterator aIt = aIndex.begin() + _nIndex; return aIt; @@ -497,7 +497,7 @@ void SAL_CALL ImplEventAttacherManager::insertEntry(sal_Int32 nIndex) { Guard< Mutex > aGuard( aLock ); if( nIndex < 0 ) - throw IllegalArgumentException(); + throw IllegalArgumentException("negative index", static_cast<cppu::OWeakObject*>(this), 1); if ( o3tl::make_unsigned(nIndex) >= aIndex.size() ) aIndex.resize(nIndex+1); @@ -532,7 +532,7 @@ void SAL_CALL ImplEventAttacherManager::attach(sal_Int32 nIndex, const Reference { Guard< Mutex > aGuard( aLock ); if( nIndex < 0 || !xObject.is() ) - throw IllegalArgumentException(); + throw IllegalArgumentException("negative index, or null object", static_cast<cppu::OWeakObject*>(this), -1); if( o3tl::make_unsigned(nIndex) >= aIndex.size() ) { @@ -589,7 +589,7 @@ void SAL_CALL ImplEventAttacherManager::detach(sal_Int32 nIndex, const Reference Guard< Mutex > aGuard( aLock ); //return; if( nIndex < 0 || o3tl::make_unsigned(nIndex) >= aIndex.size() || !xObject.is() ) - throw IllegalArgumentException(); + throw IllegalArgumentException("bad index or null object", static_cast<cppu::OWeakObject*>(this), 1); std::deque< AttacherIndex_Impl >::iterator aCurrentPosition = aIndex.begin() + nIndex; auto aObjIt = std::find_if(aCurrentPosition->aObjList.begin(), aCurrentPosition->aObjList.end(), diff --git a/comphelper/source/misc/anycompare.cxx b/comphelper/source/misc/anycompare.cxx index 72156024ccd0..106892400c7c 100644 --- a/comphelper/source/misc/anycompare.cxx +++ b/comphelper/source/misc/anycompare.cxx @@ -60,7 +60,7 @@ namespace comphelper if ( !( _lhs >>= lhs ) || !( _rhs >>= rhs ) ) - throw css::lang::IllegalArgumentException(); + throw css::lang::IllegalArgumentException("bad ordering", css::uno::Reference<css::uno::XInterface>(), -1); // FIXME Timezone? if ( lhs.Year < rhs.Year ) @@ -88,7 +88,7 @@ namespace comphelper if ( !( _lhs >>= lhs ) || !( _rhs >>= rhs ) ) - throw css::lang::IllegalArgumentException(); + throw css::lang::IllegalArgumentException("bad ordering", css::uno::Reference<css::uno::XInterface>(), -1); // FIXME Timezone? if ( lhs.Hours < rhs.Hours ) @@ -121,7 +121,7 @@ namespace comphelper if ( !( _lhs >>= lhs ) || !( _rhs >>= rhs ) ) - throw css::lang::IllegalArgumentException(); + throw css::lang::IllegalArgumentException("bad ordering", css::uno::Reference<css::uno::XInterface>(), -1); // FIXME Timezone? if ( lhs.Year < rhs.Year ) diff --git a/comphelper/source/misc/types.cxx b/comphelper/source/misc/types.cxx index 30981f3bd6c8..8887d5b5ac92 100644 --- a/comphelper/source/misc/types.cxx +++ b/comphelper/source/misc/types.cxx @@ -95,7 +95,8 @@ sal_Int32 getEnumAsINT32(const Any& _rAny) { sal_Int32 nReturn = 0; if (!::cppu::enum2int(nReturn, _rAny)) - throw IllegalArgumentException(); + throw IllegalArgumentException("enum2int failed", + css::uno::Reference<css::uno::XInterface>(), -1); return nReturn; } diff --git a/comphelper/source/property/ChainablePropertySet.cxx b/comphelper/source/property/ChainablePropertySet.cxx index c4f0d018641d..4694a89c527c 100644 --- a/comphelper/source/property/ChainablePropertySet.cxx +++ b/comphelper/source/property/ChainablePropertySet.cxx @@ -116,7 +116,7 @@ void SAL_CALL ChainablePropertySet::setPropertyValues(const Sequence< OUString > const sal_Int32 nCount = rPropertyNames.getLength(); if( nCount != rValues.getLength() ) - throw IllegalArgumentException(); + throw IllegalArgumentException("lengths do not match", static_cast<cppu::OWeakObject*>(this), -1); if( !nCount ) return; diff --git a/comphelper/source/property/opropertybag.cxx b/comphelper/source/property/opropertybag.cxx index f906374064af..62dd474c962f 100644 --- a/comphelper/source/property/opropertybag.cxx +++ b/comphelper/source/property/opropertybag.cxx @@ -197,7 +197,7 @@ namespace comphelper // If we ever have a smarter XPropertyContainer::addProperty interface, we can remove this, ehm, well, hack. Property aProperty; if ( !( _element >>= aProperty ) ) - throw IllegalArgumentException( OUString(), *this, 1 ); + throw IllegalArgumentException( "element is not Property", *this, 1 ); { osl::MutexGuard g(m_aMutex); @@ -206,7 +206,7 @@ namespace comphelper // by m_aDynamicProperties if (!m_aAllowedTypes.empty() && m_aAllowedTypes.find(aProperty.Type) == m_aAllowedTypes.end()) - throw IllegalArgumentException(OUString(), *this, 1); + throw IllegalArgumentException("not in list of allowed types", *this, 1); m_aDynamicProperties.addVoidProperty(aProperty.Name, aProperty.Type, findFreeHandle(), aProperty.Attributes); diff --git a/comphelper/source/property/propertysethelper.cxx b/comphelper/source/property/propertysethelper.cxx index 5f0f043987ee..de6e914cb859 100644 --- a/comphelper/source/property/propertysethelper.cxx +++ b/comphelper/source/property/propertysethelper.cxx @@ -111,7 +111,7 @@ void SAL_CALL PropertySetHelper::setPropertyValues( const Sequence< OUString >& const sal_Int32 nCount = rPropertyNames.getLength(); if( nCount != rValues.getLength() ) - throw IllegalArgumentException(); + throw IllegalArgumentException("lengths do not match", uno::Reference<uno::XInterface>(), -1); if( !nCount ) return; diff --git a/comphelper/source/streaming/seqstream.cxx b/comphelper/source/streaming/seqstream.cxx index 2837f27f5d35..7cffb774232f 100644 --- a/comphelper/source/streaming/seqstream.cxx +++ b/comphelper/source/streaming/seqstream.cxx @@ -117,7 +117,7 @@ void SAL_CALL SequenceInputStream::closeInput( ) void SAL_CALL SequenceInputStream::seek( sal_Int64 location ) { if ( location > m_aData.getLength() || location < 0 || location > SAL_MAX_INT32 ) - throw IllegalArgumentException(); + throw IllegalArgumentException("bad location", static_cast<cppu::OWeakObject*>(this), 1); m_nPos = static_cast<sal_Int32>(location); } |