diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-02-01 12:24:07 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-02-02 07:48:21 +0000 |
commit | c0f9bdd3e644e3ebf690aff9eb1aeec4f16dbf27 (patch) | |
tree | e5bb6d31a17587452dde579803286f68ffc73672 /comphelper | |
parent | 52360bf8dd567598593cb212ac85f0c919315618 (diff) |
unnecessary use of OUStringBuffer in throwing exceptions
Change-Id: Iec1473264426f19c31e72260dfce9494389e474f
Reviewed-on: https://gerrit.libreoffice.org/33788
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'comphelper')
-rw-r--r-- | comphelper/qa/unit/variadictemplates.cxx | 11 | ||||
-rw-r--r-- | comphelper/source/container/enumerablemap.cxx | 12 | ||||
-rw-r--r-- | comphelper/source/misc/configurationhelper.cxx | 21 | ||||
-rw-r--r-- | comphelper/source/misc/namedvaluecollection.cxx | 13 | ||||
-rw-r--r-- | comphelper/source/property/propertycontainerhelper.cxx | 17 |
5 files changed, 24 insertions, 50 deletions
diff --git a/comphelper/qa/unit/variadictemplates.cxx b/comphelper/qa/unit/variadictemplates.cxx index 77114df20fe2..2a3d0fef763f 100644 --- a/comphelper/qa/unit/variadictemplates.cxx +++ b/comphelper/qa/unit/variadictemplates.cxx @@ -44,14 +44,11 @@ inline void extract( xErrorContext, static_cast<sal_Int16>(nArg) ); } if (! fromAny(seq[nArg], &v)) { - OUStringBuffer buf; - buf.append( "Cannot extract ANY { " ); - buf.append( seq[nArg].getValueType().getTypeName() ); - buf.append( " } to " ); - buf.append( ::cppu::UnoType<T>::get().getTypeName() ); - buf.append( static_cast<sal_Unicode>('!') ); throw ::com::sun::star::lang::IllegalArgumentException( - buf.makeStringAndClear(), xErrorContext, + "Cannot extract ANY { " + + seq[nArg].getValueType().getTypeName() + + " } to " + ::cppu::UnoType<T>::get().getTypeName(), + xErrorContext, static_cast<sal_Int16>(nArg) ); } } diff --git a/comphelper/source/container/enumerablemap.cxx b/comphelper/source/container/enumerablemap.cxx index 69e89760e531..b87f2c1ea6a0 100644 --- a/comphelper/source/container/enumerablemap.cxx +++ b/comphelper/source/container/enumerablemap.cxx @@ -445,13 +445,11 @@ namespace comphelper if ( !bValid ) { - OUStringBuffer aMessage; - aMessage.append( "Incompatible value type. Found '" ); - aMessage.append( _value.getValueTypeName() ); - aMessage.append( "', where '" ); - aMessage.append( m_aData.m_aValueType.getTypeName() ); - aMessage.append( "' (or compatible type) is expected." ); - throw IllegalTypeException( aMessage.makeStringAndClear(), *const_cast< EnumerableMap* >( this ) ); + throw IllegalTypeException( + "Incompatible value type. Found '" + _value.getValueTypeName() + + "', where '" + m_aData.m_aValueType.getTypeName() + + "' (or compatible type) is expected.", + *const_cast< EnumerableMap* >( this ) ); } impl_checkNaN_throw( _value, m_aData.m_aValueType ); diff --git a/comphelper/source/misc/configurationhelper.cxx b/comphelper/source/misc/configurationhelper.cxx index 3da81093224f..6da6926daeeb 100644 --- a/comphelper/source/misc/configurationhelper.cxx +++ b/comphelper/source/misc/configurationhelper.cxx @@ -86,13 +86,8 @@ css::uno::Any ConfigurationHelper::readRelativeKey(const css::uno::Reference< cs xAccess->getByHierarchicalName(sRelPath) >>= xProps; if (!xProps.is()) { - OUStringBuffer sMsg(256); - sMsg.append("The requested path \""); - sMsg.append (sRelPath ); - sMsg.append("\" does not exists." ); - throw css::container::NoSuchElementException( - sMsg.makeStringAndClear()); + "The requested path \"" + sRelPath + "\" does not exist."); } return xProps->getPropertyValue(sKey); } @@ -109,13 +104,8 @@ void ConfigurationHelper::writeRelativeKey(const css::uno::Reference< css::uno:: xAccess->getByHierarchicalName(sRelPath) >>= xProps; if (!xProps.is()) { - OUStringBuffer sMsg(256); - sMsg.append("The requested path \""); - sMsg.append (sRelPath ); - sMsg.append("\" does not exists." ); - throw css::container::NoSuchElementException( - sMsg.makeStringAndClear()); + "The requested path \"" + sRelPath + "\" does not exist."); } xProps->setPropertyValue(sKey, aValue); } @@ -130,13 +120,8 @@ css::uno::Reference< css::uno::XInterface > ConfigurationHelper::makeSureSetNode xAccess->getByHierarchicalName(sRelPathToSet) >>= xSet; if (!xSet.is()) { - OUStringBuffer sMsg(256); - sMsg.append("The requested path \""); - sMsg.append (sRelPathToSet ); - sMsg.append("\" does not exists." ); - throw css::container::NoSuchElementException( - sMsg.makeStringAndClear()); + "The requested path \"" + sRelPathToSet + "\" does not exist." ); } css::uno::Reference< css::uno::XInterface > xNode; diff --git a/comphelper/source/misc/namedvaluecollection.cxx b/comphelper/source/misc/namedvaluecollection.cxx index 53af3a791b21..ff47011808a3 100644 --- a/comphelper/source/misc/namedvaluecollection.cxx +++ b/comphelper/source/misc/namedvaluecollection.cxx @@ -260,14 +260,11 @@ namespace comphelper return true; // argument exists, but is of wrong type - OUStringBuffer aBuffer; - aBuffer.append( "Invalid value type for '" ); - aBuffer.append ( _rValueName ); - aBuffer.append( "'.\nExpected: " ); - aBuffer.append ( _rExpectedValueType.getTypeName() ); - aBuffer.append( "\nFound: " ); - aBuffer.append ( pos->second.getValueType().getTypeName() ); - throw IllegalArgumentException( aBuffer.makeStringAndClear(), nullptr, 0 ); + throw IllegalArgumentException( + "Invalid value type for '" + _rValueName + + "'.\nExpected: " + _rExpectedValueType.getTypeName() + + "\nFound: " + pos->second.getValueType().getTypeName(), + nullptr, 0 ); } // argument does not exist diff --git a/comphelper/source/property/propertycontainerhelper.cxx b/comphelper/source/property/propertycontainerhelper.cxx index 5e7fa4f00e16..adaa6557a860 100644 --- a/comphelper/source/property/propertycontainerhelper.cxx +++ b/comphelper/source/property/propertycontainerhelper.cxx @@ -200,16 +200,13 @@ namespace { void lcl_throwIllegalPropertyValueTypeException( const PropertyDescription& _rProperty, const Any& _rValue ) { - OUStringBuffer aErrorMessage; - aErrorMessage.append( "The given value cannot be converted to the required property type." ); - aErrorMessage.append( "\n(property name \"" ); - aErrorMessage.append( _rProperty.aProperty.Name ); - aErrorMessage.append( "\", found value type \"" ); - aErrorMessage.append( _rValue.getValueType().getTypeName() ); - aErrorMessage.append( "\", required property type \"" ); - aErrorMessage.append( _rProperty.aProperty.Type.getTypeName() ); - aErrorMessage.append( "\")" ); - throw IllegalArgumentException( aErrorMessage.makeStringAndClear(), nullptr, 4 ); + throw IllegalArgumentException( + "The given value cannot be converted to the required property type." + " (property name \"" + _rProperty.aProperty.Name + + "\", found value type \"" + _rValue.getValueType().getTypeName() + + "\", required property type \"" + _rProperty.aProperty.Type.getTypeName() + + "\")", + nullptr, 4 ); } } |