diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-01-30 11:22:54 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-02-01 10:23:58 +0000 |
commit | bbd34216dca07bb37b9188147c42e64bbf875d54 (patch) | |
tree | 72e5b3db79e7857983c77b58637ff2c519c5c7e6 | |
parent | 2562ad74d1945322e9fdf8af5fc0b1f17e854c9b (diff) |
improve exception messages in stoc
Change-Id: I43716332ab916e5ec7b8ab7a4d14895d060a9bd4
Reviewed-on: https://gerrit.libreoffice.org/33692
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r-- | stoc/source/corereflection/crarray.cxx | 14 | ||||
-rw-r--r-- | stoc/source/corereflection/crcomp.cxx | 10 | ||||
-rw-r--r-- | stoc/source/corereflection/crenum.cxx | 4 | ||||
-rw-r--r-- | stoc/source/corereflection/criface.cxx | 3 | ||||
-rw-r--r-- | stoc/source/implementationregistration/implreg.cxx | 92 | ||||
-rw-r--r-- | stoc/source/inspect/introspection.cxx | 24 | ||||
-rw-r--r-- | stoc/source/invocation/invocation.cxx | 5 | ||||
-rw-r--r-- | stoc/source/javavm/javavm.cxx | 8 | ||||
-rw-r--r-- | stoc/source/security/access_controller.cxx | 5 | ||||
-rw-r--r-- | stoc/source/security/file_policy.cxx | 21 | ||||
-rw-r--r-- | stoc/source/security/permissions.cxx | 16 | ||||
-rw-r--r-- | stoc/source/servicemanager/servicemanager.cxx | 18 | ||||
-rw-r--r-- | stoc/source/simpleregistry/simpleregistry.cxx | 176 | ||||
-rw-r--r-- | stoc/source/typeconv/convert.cxx | 6 |
14 files changed, 161 insertions, 241 deletions
diff --git a/stoc/source/corereflection/crarray.cxx b/stoc/source/corereflection/crarray.cxx index 3ab0b557a28a..4bdfa4867054 100644 --- a/stoc/source/corereflection/crarray.cxx +++ b/stoc/source/corereflection/crarray.cxx @@ -80,13 +80,13 @@ void ArrayIdlClassImpl::realloc( Any & rArray, sal_Int32 nLen ) if (eTC != TypeClass_SEQUENCE) { throw IllegalArgumentException( - "no sequence given!", + "expected sequence, but found " + rArray.getValueType().getTypeName(), static_cast<XWeak *>(static_cast<OWeakObject *>(this)), 0 ); } if (nLen < 0) { throw IllegalArgumentException( - "illegal length given!", + "negative length given!", static_cast<XWeak *>(static_cast<OWeakObject *>(this)), 1 ); } @@ -104,7 +104,7 @@ sal_Int32 ArrayIdlClassImpl::getLen( const Any & rArray ) if (eTC != TypeClass_SEQUENCE) { throw IllegalArgumentException( - "no sequence given!", + "expected sequence, but found " + rArray.getValueType().getTypeName(), static_cast<XWeak *>(static_cast<OWeakObject *>(this)), 0 ); } @@ -117,7 +117,7 @@ Any ArrayIdlClassImpl::get( const Any & rArray, sal_Int32 nIndex ) if (eTC != TypeClass_SEQUENCE) { throw IllegalArgumentException( - "no sequence given!", + "expected sequence, but found " + rArray.getValueType().getTypeName(), static_cast<XWeak *>(static_cast<OWeakObject *>(this)), 0 ); } @@ -125,7 +125,7 @@ Any ArrayIdlClassImpl::get( const Any & rArray, sal_Int32 nIndex ) if (pSeq->nElements <= nIndex) { throw ArrayIndexOutOfBoundsException( - "illegal index given!", + "illegal index given, index " + OUString::number(nIndex) + " is < " + OUString::number(pSeq->nElements), static_cast<XWeak *>(static_cast<OWeakObject *>(this)) ); } @@ -147,7 +147,7 @@ void ArrayIdlClassImpl::set( Any & rArray, sal_Int32 nIndex, const Any & rNewVal if (eTC != TypeClass_SEQUENCE) { throw IllegalArgumentException( - "no sequence given!", + "expected sequence, but found " + rArray.getValueType().getTypeName(), static_cast<XWeak *>(static_cast<OWeakObject *>(this)), 0 ); } @@ -155,7 +155,7 @@ void ArrayIdlClassImpl::set( Any & rArray, sal_Int32 nIndex, const Any & rNewVal if (pSeq->nElements <= nIndex) { throw ArrayIndexOutOfBoundsException( - "illegal index given!", + "illegal index given, index " + OUString::number(nIndex) + " is < " + OUString::number(pSeq->nElements), static_cast<XWeak *>(static_cast<OWeakObject *>(this)) ); } diff --git a/stoc/source/corereflection/crcomp.cxx b/stoc/source/corereflection/crcomp.cxx index 3dd101f2979f..0a0572676a73 100644 --- a/stoc/source/corereflection/crcomp.cxx +++ b/stoc/source/corereflection/crcomp.cxx @@ -189,7 +189,7 @@ Any IdlCompFieldImpl::get( const Any & rObj ) TYPELIB_DANGER_RELEASE( pObjTD ); } throw IllegalArgumentException( - "illegal object given!", + "expected struct or exception, got " + rObj.getValueType().getTypeName(), static_cast<XWeak *>(static_cast<OWeakObject *>(this)), 0 ); } @@ -217,14 +217,14 @@ void IdlCompFieldImpl::set( const Any & rObj, const Any & rValue ) else { throw IllegalArgumentException( - "illegal value given!", + "cannot assign value to destination", static_cast<XWeak *>(static_cast<OWeakObject *>(this)), 1 ); } } TYPELIB_DANGER_RELEASE( pObjTD ); } throw IllegalArgumentException( - "illegal object given!", + "expected struct or exception, got " + rObj.getValueType().getTypeName(), static_cast<XWeak *>(static_cast<OWeakObject *>(this)), 0 ); } @@ -253,14 +253,14 @@ void IdlCompFieldImpl::set( Any & rObj, const Any & rValue ) else { throw IllegalArgumentException( - "illegal value given!", + "cannot assign to destination", static_cast<XWeak *>(static_cast<OWeakObject *>(this)), 1 ); } } TYPELIB_DANGER_RELEASE( pObjTD ); } throw IllegalArgumentException( - "illegal object given!", + "expected struct or exception, got " + rObj.getValueType().getTypeName(), static_cast<XWeak *>(static_cast<OWeakObject *>(this)), 0 ); } diff --git a/stoc/source/corereflection/crenum.cxx b/stoc/source/corereflection/crenum.cxx index b5a4f1ca1fcf..ca090763fd12 100644 --- a/stoc/source/corereflection/crenum.cxx +++ b/stoc/source/corereflection/crenum.cxx @@ -141,14 +141,14 @@ Any IdlEnumFieldImpl::get( const Any & ) void IdlEnumFieldImpl::set( const Any &, const Any & ) { throw IllegalAccessException( - "enum field is constant!", + "cannot set enum field, it is constant", static_cast<XWeak *>(static_cast<OWeakObject *>(this)) ); } void IdlEnumFieldImpl::set( Any &, const Any & ) { throw IllegalAccessException( - "enum field is constant!", + "cannot set enum field, it is constant", static_cast<XWeak *>(static_cast<OWeakObject *>(this)) ); } diff --git a/stoc/source/corereflection/criface.cxx b/stoc/source/corereflection/criface.cxx index 68465140e891..d5a3a2192d60 100644 --- a/stoc/source/corereflection/criface.cxx +++ b/stoc/source/corereflection/criface.cxx @@ -576,7 +576,8 @@ Any SAL_CALL IdlInterfaceMethodImpl::invoke( const Any & rObj, Sequence< Any > & { (*pUnoI->release)( pUnoI ); throw IllegalArgumentException( - "arguments len differ!", + "expected " + OUString::number(nParams) + + " arguments, got " + OUString::number(rArgs.getLength()), *o3tl::doAccess<Reference<XInterface>>(rObj), 1 ); } diff --git a/stoc/source/implementationregistration/implreg.cxx b/stoc/source/implementationregistration/implreg.cxx index 4dd08dcd9ba2..c9cc5a106d10 100644 --- a/stoc/source/implementationregistration/implreg.cxx +++ b/stoc/source/implementationregistration/implreg.cxx @@ -959,15 +959,9 @@ void insert_singletons( // to be registered if (! is_supported_service( service_name, xExistingService_td )) { - OUStringBuffer buf( 64 ); - buf.append( "existing singleton service (" ); - buf.append( singleton_name ); - buf.append( '=' ); - buf.append( existing_name ); - buf.append( ") does not support given one: " ); - buf.append( service_name ); throw registry::CannotRegisterImplementationException( - buf.makeStringAndClear() ); + "existing singleton service (" + singleton_name + "=" + existing_name + ") " + " does not support given one: " + service_name); } } catch (const container::NoSuchElementException & exc) @@ -1320,12 +1314,9 @@ void ImplementationRegistration::initialize( { if( aArgs.getLength() != 4 ) { - OUStringBuffer buf; - buf.append( "ImplementationRegistration::initialize() expects 4 parameters, got " ); - buf.append( (sal_Int32) aArgs.getLength() ); - throw IllegalArgumentException( buf.makeStringAndClear(), - Reference<XInterface > (), - 0 ); + throw IllegalArgumentException( + "ImplementationRegistration::initialize() expects 4 parameters, got " + OUString::number( aArgs.getLength() ), + Reference<XInterface > (), 0 ); } Reference< XImplementationLoader > rLoader; @@ -1338,15 +1329,11 @@ void ImplementationRegistration::initialize( aArgs.getConstArray()[0] >>= rLoader; } if( !rLoader.is()) { - OUStringBuffer buf; - buf.append( "ImplementationRegistration::initialize() invalid first parameter," - "expected " ); - buf.append( cppu::UnoType<decltype(rLoader)>::get().getTypeName() ); - buf.append( ", got " ); - buf.append( aArgs.getConstArray()[0].getValueTypeName() ); - throw IllegalArgumentException( buf.makeStringAndClear(), - Reference< XInterface > (), - 0 ); + throw IllegalArgumentException( + "ImplementationRegistration::initialize() invalid first parameter," + "expected " + cppu::UnoType<decltype(rLoader)>::get().getTypeName() + + ", got " + aArgs.getConstArray()[0].getValueTypeName(), + Reference< XInterface > (), 0 ); } // 2nd argument : The service name of the loader. This name is written into the registry @@ -1354,13 +1341,10 @@ void ImplementationRegistration::initialize( aArgs.getConstArray()[1] >>= loaderServiceName; } if( loaderServiceName.isEmpty() ) { - OUStringBuffer buf; - buf.append( "ImplementationRegistration::initialize() invalid second parameter," - "expected string, got " ); - buf.append( aArgs.getConstArray()[1].getValueTypeName() ); - throw IllegalArgumentException( buf.makeStringAndClear(), - Reference< XInterface > (), - 0 ); + throw IllegalArgumentException( + "ImplementationRegistration::initialize() invalid second parameter," + "expected string, got " + aArgs.getConstArray()[1].getValueTypeName(), + Reference< XInterface > (), 0 ); } // 3rd argument : The file name of the dll, that contains the loader @@ -1368,13 +1352,10 @@ void ImplementationRegistration::initialize( aArgs.getConstArray()[2] >>= locationUrl; } if( locationUrl.isEmpty() ) { - OUStringBuffer buf; - buf.append( "ImplementationRegistration::initialize() invalid third parameter," - "expected string, got " ); - buf.append( aArgs.getConstArray()[2].getValueTypeName() ); - throw IllegalArgumentException( buf.makeStringAndClear(), - Reference< XInterface > (), - 0 ); + throw IllegalArgumentException( + "ImplementationRegistration::initialize() invalid third parameter," + "expected string, got " + aArgs.getConstArray()[2].getValueTypeName(), + Reference< XInterface > (), 0 ); } // 4th argument : The registry, the service should be written to @@ -1385,15 +1366,11 @@ void ImplementationRegistration::initialize( if( !rReg.is() ) { rReg = getRegistryFromServiceManager(); if( !rReg.is() ) { - OUStringBuffer buf; - buf.append( "ImplementationRegistration::initialize() invalid fourth parameter," - "expected " ); - buf.append( cppu::UnoType<decltype(rReg)>::get().getTypeName() ); - buf.append( ", got " ); - buf.append( aArgs.getConstArray()[3].getValueTypeName() ); - throw IllegalArgumentException( buf.makeStringAndClear(), - Reference< XInterface > (), - 0 ); + throw IllegalArgumentException( + "ImplementationRegistration::initialize() invalid fourth parameter," + "expected " + cppu::UnoType<decltype(rReg)>::get().getTypeName() + + ", got " + aArgs.getConstArray()[3].getValueTypeName(), + Reference< XInterface > (), 0 ); } } @@ -1460,12 +1437,9 @@ void ImplementationRegistration::prepareRegister( } else { - OUStringBuffer buf( 128 ); - buf.append( "ImplementationRegistration::registerImplementation() - The service " ); - buf.append( activatorName ); - buf.append( " cannot be instantiated\n" ); throw CannotRegisterImplementationException( - buf.makeStringAndClear() ); + "ImplementationRegistration::registerImplementation() - The service " + + activatorName + " cannot be instantiated" ); } } catch( CannotRegisterImplementationException & ) @@ -1474,23 +1448,15 @@ void ImplementationRegistration::prepareRegister( } catch( const InvalidRegistryException & e ) { - OUStringBuffer buf; - buf.append( "ImplementationRegistration::registerImplementation() " - "InvalidRegistryException during registration (" ); - buf.append( e.Message ); - buf.append( ")" ); throw CannotRegisterImplementationException( - buf.makeStringAndClear() ); + "ImplementationRegistration::registerImplementation() " + "InvalidRegistryException during registration (" + e.Message + ")" ); } catch( const MergeConflictException & e ) { - OUStringBuffer buf; - buf.append( "ImplementationRegistration::registerImplementation() " - "MergeConflictException during registration (" ); - buf.append( e.Message ); - buf.append( ")" ); throw CannotRegisterImplementationException( - buf.makeStringAndClear() ); + "ImplementationRegistration::registerImplementation() " + "MergeConflictException during registration (" + e.Message + ")" ); } } else diff --git a/stoc/source/inspect/introspection.cxx b/stoc/source/inspect/introspection.cxx index 75443c0bd55a..033f2e7a8536 100644 --- a/stoc/source/inspect/introspection.cxx +++ b/stoc/source/inspect/introspection.cxx @@ -374,7 +374,7 @@ void IntrospectionAccessStatic_Impl::setPropertyValue( const Any& obj, const OUS if( i != -1 ) setPropertyValueByIndex( obj, (sal_Int32)i, aValue ); else - throw UnknownPropertyException(); + throw UnknownPropertyException(aPropertyName); } void IntrospectionAccessStatic_Impl::setPropertyValueByIndex(const Any& obj, sal_Int32 nSequenceIndex, const Any& aValue) const @@ -385,16 +385,22 @@ void IntrospectionAccessStatic_Impl::setPropertyValueByIndex(const Any& obj, sal if( !(obj >>= xInterface) ) { TypeClass eObjType = obj.getValueType().getTypeClass(); - if( nSequenceIndex >= mnPropCount || ( eObjType != TypeClass_STRUCT && eObjType != TypeClass_EXCEPTION ) ) - { - throw IllegalArgumentException(); - } + if( nSequenceIndex >= mnPropCount) + throw IllegalArgumentException( + "IntrospectionAccessStatic_Impl::setPropertyValueByIndex(), index > propertyCount, " + + OUString::number(nSequenceIndex) + " > " + OUString::number(mnPropCount), + Reference<XInterface>(), 0); + if( eObjType != TypeClass_STRUCT && eObjType != TypeClass_EXCEPTION ) + throw IllegalArgumentException( + "IntrospectionAccessStatic_Impl::setPropertyValueByIndex(), expected struct or exception, got" + + obj.getValueType().getTypeName(), Reference<XInterface>(), 0); } // Test flags if( (maAllPropertySeq[ nSequenceIndex ].Attributes & READONLY) != 0 ) { - throw UnknownPropertyException(); + throw UnknownPropertyException( + "IntrospectionAccessStatic_Impl::setPropertyValueByIndex(), property at index " + OUString::number(nSequenceIndex) + " is readonly"); } switch( maMapTypeSeq[ nSequenceIndex ] ) @@ -512,7 +518,7 @@ Any IntrospectionAccessStatic_Impl::getPropertyValue( const Any& obj, const OUSt if( i != -1 ) return getPropertyValueByIndex( obj, i ); - throw UnknownPropertyException(); + throw UnknownPropertyException(aPropertyName); } Any IntrospectionAccessStatic_Impl::getPropertyValueByIndex(const Any& obj, sal_Int32 nSequenceIndex) const @@ -1250,7 +1256,7 @@ Property ImplIntrospectionAccess::getProperty(const OUString& Name, sal_Int32 Pr } } if( !bFound ) - throw NoSuchElementException() ; + throw NoSuchElementException(Name); return aRet; } @@ -1335,7 +1341,7 @@ Reference<XIdlMethod> ImplIntrospectionAccess::getMethod(const OUString& Name, s } } if( !xRet.is() ) - throw NoSuchMethodException(); + throw NoSuchMethodException(Name); return xRet; } diff --git a/stoc/source/invocation/invocation.cxx b/stoc/source/invocation/invocation.cxx index fea9e93cd43b..ab873ac181d2 100644 --- a/stoc/source/invocation/invocation.cxx +++ b/stoc/source/invocation/invocation.cxx @@ -607,7 +607,8 @@ Any Invocation_Impl::invoke( const OUString& FunctionName, const Sequence<Any>& if (nFParamsLen != InParams.getLength()) { throw IllegalArgumentException( - "incorrect number of parameters passed invoking function " + FunctionName, + "incorrect number of parameters passed invoking function " + FunctionName + + "expected " + OUString::number(nFParamsLen) + ", got " + OUString::number(InParams.getLength()), static_cast<OWeakObject *>(this), (sal_Int16) 1 ); } @@ -887,7 +888,7 @@ InvocationInfo SAL_CALL Invocation_Impl::getInfoForName( const OUString& aName, if( !bFound ) { throw IllegalArgumentException( - "Unknown name, getExactName() failed!", + "getExactName(), Unknown name " + aName, static_cast<XWeak *>(static_cast<OWeakObject *>(this)), 0 ); } return aRetInfo; diff --git a/stoc/source/javavm/javavm.cxx b/stoc/source/javavm/javavm.cxx index 86eb7cb7ee78..ee5069d98752 100644 --- a/stoc/source/javavm/javavm.cxx +++ b/stoc/source/javavm/javavm.cxx @@ -621,7 +621,7 @@ JavaVirtualMachine::initialize(css::uno::Sequence< css::uno::Any > const & osl::MutexGuard aGuard(m_aMutex); if (m_bDisposed) throw css::lang::DisposedException( - OUString(), static_cast< cppu::OWeakObject * >(this)); + "", static_cast< cppu::OWeakObject * >(this)); if (m_xUnoVirtualMachine.is()) throw css::uno::RuntimeException( "bad call to initialize", @@ -693,7 +693,7 @@ JavaVirtualMachine::getJavaVM(css::uno::Sequence< sal_Int8 > const & rProcessId) osl::MutexGuard aGuard(m_aMutex); if (m_bDisposed) throw css::lang::DisposedException( - OUString(), static_cast< cppu::OWeakObject * >(this)); + "", static_cast< cppu::OWeakObject * >(this)); css::uno::Sequence< sal_Int8 > aId(16); rtl_getGlobalProcessId(reinterpret_cast< sal_uInt8 * >(aId.getArray())); enum ReturnType { @@ -972,7 +972,7 @@ void SAL_CALL JavaVirtualMachine::registerThread() osl::MutexGuard aGuard(m_aMutex); if (m_bDisposed) throw css::lang::DisposedException( - OUString(), static_cast< cppu::OWeakObject * >(this)); + "", static_cast< cppu::OWeakObject * >(this)); if (!m_xUnoVirtualMachine.is()) throw css::uno::RuntimeException( "JavaVirtualMachine::registerThread: null VirtualMachine", @@ -1004,7 +1004,7 @@ void SAL_CALL JavaVirtualMachine::revokeThread() osl::MutexGuard aGuard(m_aMutex); if (m_bDisposed) throw css::lang::DisposedException( - OUString(), static_cast< cppu::OWeakObject * >(this)); + "", static_cast< cppu::OWeakObject * >(this)); if (!m_xUnoVirtualMachine.is()) throw css::uno::RuntimeException( "JavaVirtualMachine::revokeThread: null VirtualMachine", diff --git a/stoc/source/security/access_controller.cxx b/stoc/source/security/access_controller.cxx index 193c98482569..179ac8015ade 100644 --- a/stoc/source/security/access_controller.cxx +++ b/stoc/source/security/access_controller.cxx @@ -699,10 +699,7 @@ PermissionCollection AccessController::getEffectivePermissions( catch (const security::AccessControlException & exc) // wrapped into DeploymentException { clearPostPoned(); // safety: exception could have happened before checking postponed? - OUStringBuffer buf( 64 ); - buf.append( "deployment error (AccessControlException occurred): " ); - buf.append( exc.Message ); - throw DeploymentException( buf.makeStringAndClear(), exc.Context ); + throw DeploymentException( "deployment error (AccessControlException occurred): " + exc.Message, exc.Context ); } catch (RuntimeException &) { diff --git a/stoc/source/security/file_policy.cxx b/stoc/source/security/file_policy.cxx index 6fada62ca405..8a388fedc2e4 100644 --- a/stoc/source/security/file_policy.cxx +++ b/stoc/source/security/file_policy.cxx @@ -328,16 +328,11 @@ sal_Unicode PolicyReader::get() void PolicyReader::error( OUString const & msg ) { - OUStringBuffer buf( 32 ); - buf.append( "error processing file \"" ); - buf.append( m_fileName ); - buf.append( "\" [line " ); - buf.append( m_linepos ); - buf.append( ", column " ); - buf.append( m_pos ); - buf.append( "] " ); - buf.append( msg ); - throw RuntimeException( buf.makeStringAndClear() ); + throw RuntimeException( + "error processing file \"" + m_fileName + + "\" [line " + OUString::number(m_linepos) + + ", column " + OUString::number(m_pos) + + "] " + msg); } PolicyReader::PolicyReader( OUString const & fileName, AccessControl & ac ) @@ -349,11 +344,7 @@ PolicyReader::PolicyReader( OUString const & fileName, AccessControl & ac ) ac.checkFilePermission( m_fileName, "read" ); if (osl_File_E_None != ::osl_openFile( m_fileName.pData, &m_file, osl_File_OpenFlag_Read )) { - OUStringBuffer buf( 32 ); - buf.append( "cannot open file \"" ); - buf.append( m_fileName ); - buf.append( "\"!" ); - throw RuntimeException( buf.makeStringAndClear() ); + throw RuntimeException( "cannot open file \"" + m_fileName + "\"!" ); } } diff --git a/stoc/source/security/permissions.cxx b/stoc/source/security/permissions.cxx index 7e98f96cfd11..8fc189ffd3d4 100644 --- a/stoc/source/security/permissions.cxx +++ b/stoc/source/security/permissions.cxx @@ -494,10 +494,7 @@ PermissionCollection::PermissionCollection( } else { - OUStringBuffer buf( 48 ); - buf.append( "checking for unsupported permission type: " ); - buf.append( perm_type.getTypeName() ); - throw RuntimeException( buf.makeStringAndClear() ); + throw RuntimeException( "checking for unsupported permission type: " + perm_type.getTypeName() ); } } } @@ -544,11 +541,9 @@ static void demanded_diag( static void throwAccessControlException( Permission const & perm, Any const & demanded_perm ) { - OUStringBuffer buf( 48 ); - buf.append( "access denied: " ); - buf.append( perm.toString() ); throw security::AccessControlException( - buf.makeStringAndClear(), Reference< XInterface >(), demanded_perm ); + "access denied: " + perm.toString(), + Reference< XInterface >(), demanded_perm ); } void PermissionCollection::checkPermission( Any const & perm ) const @@ -611,10 +606,7 @@ void PermissionCollection::checkPermission( Any const & perm ) const } else { - OUStringBuffer buf( 48 ); - buf.append( "checking for unsupported permission type: " ); - buf.append( demanded_type.getTypeName() ); - throw RuntimeException( buf.makeStringAndClear() ); + throw RuntimeException( "checking for unsupported permission type: " + demanded_type.getTypeName() ); } } diff --git a/stoc/source/servicemanager/servicemanager.cxx b/stoc/source/servicemanager/servicemanager.cxx index 69ccb3f387b3..eb5685a29b76 100644 --- a/stoc/source/servicemanager/servicemanager.cxx +++ b/stoc/source/servicemanager/servicemanager.cxx @@ -183,7 +183,7 @@ Any ServiceEnumeration_Impl::nextElement() { MutexGuard aGuard( aMutex ); if( nIt == aFactories.getLength() ) - throw NoSuchElementException(); + throw NoSuchElementException("no more elements"); return Any( &aFactories.getConstArray()[nIt++], cppu::UnoType<XInterface>::get()); } @@ -266,7 +266,7 @@ Any ImplementationEnumeration_Impl::nextElement() { MutexGuard aGuard( aMutex ); if( aIt == aImplementationMap.end() ) - throw NoSuchElementException(); + throw NoSuchElementException("no more elements"); Any ret( &(*aIt), cppu::UnoType<XInterface>::get()); ++aIt; @@ -744,28 +744,28 @@ void OServiceManager::addPropertyChangeListener( const OUString&, const Reference<XPropertyChangeListener >&) { check_undisposed(); - throw UnknownPropertyException(); + throw UnknownPropertyException("unsupported"); } void OServiceManager::removePropertyChangeListener( const OUString&, const Reference<XPropertyChangeListener >&) { check_undisposed(); - throw UnknownPropertyException(); + throw UnknownPropertyException("unsupported"); } void OServiceManager::addVetoableChangeListener( const OUString&, const Reference<XVetoableChangeListener >&) { check_undisposed(); - throw UnknownPropertyException(); + throw UnknownPropertyException("unsupported"); } void OServiceManager::removeVetoableChangeListener( const OUString&, const Reference<XVetoableChangeListener >&) { check_undisposed(); - throw UnknownPropertyException(); + throw UnknownPropertyException("unsupported"); } // OServiceManager @@ -1061,7 +1061,7 @@ void OServiceManager::insert( const Any & Element ) if( Element.getValueTypeClass() != TypeClass_INTERFACE ) { throw IllegalArgumentException( - "no interface given!", + "exception interface, got " + Element.getValueType().getTypeName(), Reference< XInterface >(), 0 ); } Reference<XInterface > xEle( Element, UNO_QUERY_THROW ); @@ -1134,7 +1134,7 @@ void OServiceManager::remove( const Any & Element ) else { throw IllegalArgumentException( - "neither interface nor string given!", + "expected interface or string, got " + Element.getValueType().getTypeName(), Reference< XInterface >(), 0 ); } @@ -1148,7 +1148,7 @@ void OServiceManager::remove( const Any & Element ) if( aIt == m_ImplementationMap.end() ) { throw NoSuchElementException( - "element is not in!", + "element not found", static_cast< OWeakObject * >(this) ); } //First remove all factories which have been loaded by ORegistryServiceManager. diff --git a/stoc/source/simpleregistry/simpleregistry.cxx b/stoc/source/simpleregistry/simpleregistry.cxx index 3035bdad527d..acf1c86216bd 100644 --- a/stoc/source/simpleregistry/simpleregistry.cxx +++ b/stoc/source/simpleregistry/simpleregistry.cxx @@ -211,9 +211,8 @@ css::registry::RegistryValueType Key::getValueType() break; default: throw css::registry::InvalidRegistryException( - (("com.sun.star.registry.SimpleRegistry key getValueType:" - " underlying RegistryKey::getValueInfo() = ") + - OUString::number(static_cast<int>(err))), + "com.sun.star.registry.SimpleRegistry key getValueType:" + " underlying RegistryKey::getValueInfo() = " + OUString::number(static_cast<int>(err)), static_cast< OWeakObject * >(this)); } switch (type) { @@ -254,9 +253,8 @@ sal_Int32 Key::getLongValue() static_cast< OWeakObject * >(this)); default: throw css::registry::InvalidRegistryException( - (("com.sun.star.registry.SimpleRegistry key getLongValue:" - " underlying RegistryKey::getValue() = ") + - OUString::number(static_cast<int>(err))), + "com.sun.star.registry.SimpleRegistry key getLongValue:" + " underlying RegistryKey::getValue() = " + OUString::number(static_cast<int>(err)), static_cast< OWeakObject * >(this)); } return value; @@ -269,9 +267,8 @@ void Key::setLongValue(sal_Int32 value) OUString(), RegValueType::LONG, &value, sizeof (sal_Int32)); if (err != RegError::NO_ERROR) { throw css::registry::InvalidRegistryException( - (("com.sun.star.registry.SimpleRegistry key setLongValue:" - " underlying RegistryKey::setValue() = ") + - OUString::number(static_cast<int>(err))), + "com.sun.star.registry.SimpleRegistry key setLongValue:" + " underlying RegistryKey::setValue() = " + OUString::number(static_cast<int>(err)), static_cast< OWeakObject * >(this)); } } @@ -294,9 +291,8 @@ css::uno::Sequence< sal_Int32 > Key::getLongListValue() static_cast< OWeakObject * >(this)); default: throw css::registry::InvalidRegistryException( - (("com.sun.star.registry.SimpleRegistry key getLongListValue:" - " underlying RegistryKey::getLongListValue() = ") + - OUString::number(static_cast<int>(err))), + "com.sun.star.registry.SimpleRegistry key getLongListValue:" + " underlying RegistryKey::getLongListValue() = " + OUString::number(static_cast<int>(err)), static_cast< OWeakObject * >(this)); } sal_uInt32 n = list.getLength(); @@ -324,9 +320,8 @@ void Key::setLongListValue(css::uno::Sequence< sal_Int32 > const & seqValue) OUString(), list.data(), static_cast< sal_uInt32 >(list.size())); if (err != RegError::NO_ERROR) { throw css::registry::InvalidRegistryException( - (("com.sun.star.registry.SimpleRegistry key setLongListValue:" - " underlying RegistryKey::setLongListValue() = ") + - OUString::number(static_cast<int>(err))), + "com.sun.star.registry.SimpleRegistry key setLongListValue:" + " underlying RegistryKey::setLongListValue() = " + OUString::number(static_cast<int>(err)), static_cast< OWeakObject * >(this)); } } @@ -339,16 +334,14 @@ OUString Key::getAsciiValue() RegError err = key_.getValueInfo(OUString(), &type, &size); if (err != RegError::NO_ERROR) { throw css::registry::InvalidRegistryException( - (("com.sun.star.registry.SimpleRegistry key getAsciiValue:" - " underlying RegistryKey::getValueInfo() = ") + - OUString::number(static_cast<int>(err))), + "com.sun.star.registry.SimpleRegistry key getAsciiValue:" + " underlying RegistryKey::getValueInfo() = " + OUString::number(static_cast<int>(err)), static_cast< OWeakObject * >(this)); } if (type != RegValueType::STRING) { throw css::registry::InvalidValueException( - (("com.sun.star.registry.SimpleRegistry key getAsciiValue:" - " underlying RegistryKey type = ") + - OUString::number(static_cast<int>(type))), + "com.sun.star.registry.SimpleRegistry key getAsciiValue:" + " underlying RegistryKey type = " + OUString::number(static_cast<int>(type)), static_cast< OWeakObject * >(this)); } // size contains terminating null (error in underlying registry.cxx): @@ -369,9 +362,8 @@ OUString Key::getAsciiValue() err = key_.getValue(OUString(), &list[0]); if (err != RegError::NO_ERROR) { throw css::registry::InvalidRegistryException( - (("com.sun.star.registry.SimpleRegistry key getAsciiValue:" - " underlying RegistryKey::getValue() = ") + - OUString::number(static_cast<int>(err))), + "com.sun.star.registry.SimpleRegistry key getAsciiValue:" + " underlying RegistryKey::getValue() = " + OUString::number(static_cast<int>(err)), static_cast< OWeakObject * >(this)); } if (list[size - 1] != '\0') { @@ -391,7 +383,7 @@ OUString Key::getAsciiValue() { throw css::registry::InvalidValueException( "com.sun.star.registry.SimpleRegistry key getAsciiValue:" - " underlying RegistryKey not UTF-8" , + " underlying RegistryKey not UTF-8", static_cast< OWeakObject * >(this)); } return value; @@ -417,9 +409,8 @@ void Key::setAsciiValue(OUString const & value) // +1 for terminating null (error in underlying registry.cxx) if (err != RegError::NO_ERROR) { throw css::registry::InvalidRegistryException( - (("com.sun.star.registry.SimpleRegistry key setAsciiValue:" - " underlying RegistryKey::setValue() = ") + - OUString::number(static_cast<int>(err))), + "com.sun.star.registry.SimpleRegistry key setAsciiValue:" + " underlying RegistryKey::setValue() = " + OUString::number(static_cast<int>(err)), static_cast< OWeakObject * >(this)); } } @@ -442,10 +433,9 @@ css::uno::Sequence< OUString > Key::getAsciiListValue() static_cast< OWeakObject * >(this)); default: throw css::registry::InvalidRegistryException( - (("com.sun.star.registry.SimpleRegistry key" - " getAsciiListValue: underlying" - " RegistryKey::getStringListValue() = ") + - OUString::number(static_cast<int>(err))), + "com.sun.star.registry.SimpleRegistry key" + " getAsciiListValue: underlying" + " RegistryKey::getStringListValue() = " + OUString::number(static_cast<int>(err)), static_cast< OWeakObject * >(this)); } sal_uInt32 n = list.getLength(); @@ -506,10 +496,9 @@ void Key::setAsciiListValue( OUString(), list2.data(), static_cast< sal_uInt32 >(list2.size())); if (err != RegError::NO_ERROR) { throw css::registry::InvalidRegistryException( - (("com.sun.star.registry.SimpleRegistry key" - " setAsciiListValue: underlying" - " RegistryKey::setStringListValue() = ") + - OUString::number(static_cast<int>(err))), + "com.sun.star.registry.SimpleRegistry key" + " setAsciiListValue: underlying" + " RegistryKey::setStringListValue() = " + OUString::number(static_cast<int>(err)), static_cast< OWeakObject * >(this)); } } @@ -522,16 +511,14 @@ OUString Key::getStringValue() RegError err = key_.getValueInfo(OUString(), &type, &size); if (err != RegError::NO_ERROR) { throw css::registry::InvalidRegistryException( - (("com.sun.star.registry.SimpleRegistry key getStringValue:" - " underlying RegistryKey::getValueInfo() = ") + - OUString::number(static_cast<int>(err))), + "com.sun.star.registry.SimpleRegistry key getStringValue:" + " underlying RegistryKey::getValueInfo() = " + OUString::number(static_cast<int>(err)), static_cast< OWeakObject * >(this)); } if (type != RegValueType::UNICODE) { throw css::registry::InvalidValueException( - (("com.sun.star.registry.SimpleRegistry key getStringValue:" - " underlying RegistryKey type = ") + - OUString::number(static_cast<int>(type))), + "com.sun.star.registry.SimpleRegistry key getStringValue:" + " underlying RegistryKey type = " + OUString::number(static_cast<int>(type)), static_cast< OWeakObject * >(this)); } // size contains terminating null and is *2 (error in underlying @@ -553,9 +540,8 @@ OUString Key::getStringValue() err = key_.getValue(OUString(), &list[0]); if (err != RegError::NO_ERROR) { throw css::registry::InvalidRegistryException( - (("com.sun.star.registry.SimpleRegistry key getStringValue:" - " underlying RegistryKey::getValue() = ") + - OUString::number(static_cast<int>(err))), + "com.sun.star.registry.SimpleRegistry key getStringValue:" + " underlying RegistryKey::getValue() = " + OUString::number(static_cast<int>(err)), static_cast< OWeakObject * >(this)); } if (list[size/2 - 1] != 0) { @@ -578,9 +564,8 @@ void Key::setStringValue(OUString const & value) // +1 for terminating null (error in underlying registry.cxx) if (err != RegError::NO_ERROR) { throw css::registry::InvalidRegistryException( - (("com.sun.star.registry.SimpleRegistry key setStringValue:" - " underlying RegistryKey::setValue() = ") + - OUString::number(static_cast<int>(err))), + "com.sun.star.registry.SimpleRegistry key setStringValue:" + " underlying RegistryKey::setValue() = " + OUString::number(static_cast<int>(err)), static_cast< OWeakObject * >(this)); } } @@ -603,10 +588,9 @@ css::uno::Sequence< OUString > Key::getStringListValue() static_cast< OWeakObject * >(this)); default: throw css::registry::InvalidRegistryException( - (("com.sun.star.registry.SimpleRegistry key" - " getStringListValue: underlying" - " RegistryKey::getUnicodeListValue() = ") + - OUString::number(static_cast<int>(err))), + "com.sun.star.registry.SimpleRegistry key" + " getStringListValue: underlying" + " RegistryKey::getUnicodeListValue() = " + OUString::number(static_cast<int>(err)), static_cast< OWeakObject * >(this)); } sal_uInt32 n = list.getLength(); @@ -636,10 +620,9 @@ void Key::setStringListValue( OUString(), list.data(), static_cast< sal_uInt32 >(list.size())); if (err != RegError::NO_ERROR) { throw css::registry::InvalidRegistryException( - (("com.sun.star.registry.SimpleRegistry key" - " setStringListValue: underlying" - " RegistryKey::setUnicodeListValue() = ") + - OUString::number(static_cast<int>(err))), + "com.sun.star.registry.SimpleRegistry key" + " setStringListValue: underlying" + " RegistryKey::setUnicodeListValue() = " + OUString::number(static_cast<int>(err)), static_cast< OWeakObject * >(this)); } } @@ -652,16 +635,14 @@ css::uno::Sequence< sal_Int8 > Key::getBinaryValue() RegError err = key_.getValueInfo(OUString(), &type, &size); if (err != RegError::NO_ERROR) { throw css::registry::InvalidRegistryException( - (("com.sun.star.registry.SimpleRegistry key getBinaryValue:" - " underlying RegistryKey::getValueInfo() = ") + - OUString::number(static_cast<int>(err))), + "com.sun.star.registry.SimpleRegistry key getBinaryValue:" + " underlying RegistryKey::getValueInfo() = " + OUString::number(static_cast<int>(err)), static_cast< OWeakObject * >(this)); } if (type != RegValueType::BINARY) { throw css::registry::InvalidValueException( - (("com.sun.star.registry.SimpleRegistry key getBinaryValue:" - " underlying RegistryKey type = ") + - OUString::number(static_cast<int>(type))), + "com.sun.star.registry.SimpleRegistry key getBinaryValue:" + " underlying RegistryKey type = " + OUString::number(static_cast<int>(type)), static_cast< OWeakObject * >(this)); } if (size > SAL_MAX_INT32) { @@ -674,9 +655,8 @@ css::uno::Sequence< sal_Int8 > Key::getBinaryValue() err = key_.getValue(OUString(), value.getArray()); if (err != RegError::NO_ERROR) { throw css::registry::InvalidRegistryException( - (("com.sun.star.registry.SimpleRegistry key getBinaryValue:" - " underlying RegistryKey::getValue() = ") + - OUString::number(static_cast<int>(err))), + "com.sun.star.registry.SimpleRegistry key getBinaryValue:" + " underlying RegistryKey::getValue() = " + OUString::number(static_cast<int>(err)), static_cast< OWeakObject * >(this)); } return value; @@ -691,9 +671,8 @@ void Key::setBinaryValue(css::uno::Sequence< sal_Int8 > const & value) static_cast< sal_uInt32 >(value.getLength())); if (err != RegError::NO_ERROR) { throw css::registry::InvalidRegistryException( - (("com.sun.star.registry.SimpleRegistry key setBinaryValue:" - " underlying RegistryKey::setValue() = ") + - OUString::number(static_cast<int>(err))), + "com.sun.star.registry.SimpleRegistry key setBinaryValue:" + " underlying RegistryKey::setValue() = " + OUString::number(static_cast<int>(err)), static_cast< OWeakObject * >(this)); } } @@ -711,9 +690,8 @@ css::uno::Reference< css::registry::XRegistryKey > Key::openKey( return css::uno::Reference< css::registry::XRegistryKey >(); default: throw css::registry::InvalidRegistryException( - (("com.sun.star.registry.SimpleRegistry key openKey:" - " underlying RegistryKey::openKey() = ") + - OUString::number(static_cast<int>(err))), + "com.sun.star.registry.SimpleRegistry key openKey:" + " underlying RegistryKey::openKey() = " + OUString::number(static_cast<int>(err)), static_cast< OWeakObject * >(this)); } } @@ -731,9 +709,8 @@ css::uno::Reference< css::registry::XRegistryKey > Key::createKey( return css::uno::Reference< css::registry::XRegistryKey >(); default: throw css::registry::InvalidRegistryException( - (("com.sun.star.registry.SimpleRegistry key createKey:" - " underlying RegistryKey::createKey() = ") + - OUString::number(static_cast<int>(err))), + "com.sun.star.registry.SimpleRegistry key createKey:" + " underlying RegistryKey::createKey() = " + OUString::number(static_cast<int>(err)), static_cast< OWeakObject * >(this)); } } @@ -744,9 +721,8 @@ void Key::closeKey() RegError err = key_.closeKey(); if (err != RegError::NO_ERROR) { throw css::registry::InvalidRegistryException( - (("com.sun.star.registry.SimpleRegistry key closeKey:" - " underlying RegistryKey::closeKey() = ") + - OUString::number(static_cast<int>(err))), + "com.sun.star.registry.SimpleRegistry key closeKey:" + " underlying RegistryKey::closeKey() = " + OUString::number(static_cast<int>(err)), static_cast< OWeakObject * >(this)); } } @@ -757,9 +733,8 @@ void Key::deleteKey(OUString const & rKeyName) RegError err = key_.deleteKey(rKeyName); if (err != RegError::NO_ERROR) { throw css::registry::InvalidRegistryException( - (("com.sun.star.registry.SimpleRegistry key deleteKey:" - " underlying RegistryKey::deleteKey() = ") + - OUString::number(static_cast<int>(err))), + "com.sun.star.registry.SimpleRegistry key deleteKey:" + " underlying RegistryKey::deleteKey() = " + OUString::number(static_cast<int>(err)), static_cast< OWeakObject * >(this)); } } @@ -772,9 +747,8 @@ Key::openKeys() RegError err = key_.openSubKeys(OUString(), list); if (err != RegError::NO_ERROR) { throw css::registry::InvalidRegistryException( - (("com.sun.star.registry.SimpleRegistry key openKeys:" - " underlying RegistryKey::openSubKeys() = ") + - OUString::number(static_cast<int>(err))), + "com.sun.star.registry.SimpleRegistry key openKeys:" + " underlying RegistryKey::openSubKeys() = " + OUString::number(static_cast<int>(err)), static_cast< OWeakObject * >(this)); } sal_uInt32 n = list.getLength(); @@ -800,9 +774,8 @@ css::uno::Sequence< OUString > Key::getKeyNames() RegError err = key_.getKeyNames(OUString(), list); if (err != RegError::NO_ERROR) { throw css::registry::InvalidRegistryException( - (("com.sun.star.registry.SimpleRegistry key getKeyNames:" - " underlying RegistryKey::getKeyNames() = ") + - OUString::number(static_cast<int>(err))), + "com.sun.star.registry.SimpleRegistry key getKeyNames:" + " underlying RegistryKey::getKeyNames() = " + OUString::number(static_cast<int>(err)), static_cast< OWeakObject * >(this)); } sal_uInt32 n = list.getLength(); @@ -848,9 +821,8 @@ OUString Key::getResolvedName(OUString const & aKeyName) RegError err = key_.getResolvedKeyName(aKeyName, resolved); if (err != RegError::NO_ERROR) { throw css::registry::InvalidRegistryException( - (("com.sun.star.registry.SimpleRegistry key getResolvedName:" - " underlying RegistryKey::getResolvedName() = ") + - OUString::number(static_cast<int>(err))), + "com.sun.star.registry.SimpleRegistry key getResolvedName:" + " underlying RegistryKey::getResolvedName() = " + OUString::number(static_cast<int>(err)), static_cast< OWeakObject * >(this)); } return resolved; @@ -873,10 +845,8 @@ void SimpleRegistry::open( } if (err != RegError::NO_ERROR) { throw css::registry::InvalidRegistryException( - ("com.sun.star.registry.SimpleRegistry.open(" + - rURL + - "): underlying Registry::open/create() = " + - OUString::number(static_cast<int>(err))), + "com.sun.star.registry.SimpleRegistry.open(" + rURL + + "): underlying Registry::open/create() = " + OUString::number(static_cast<int>(err)), static_cast< OWeakObject * >(this)); } } @@ -892,9 +862,8 @@ void SimpleRegistry::close() RegError err = registry_.close(); if (err != RegError::NO_ERROR) { throw css::registry::InvalidRegistryException( - (("com.sun.star.registry.SimpleRegistry.close:" - " underlying Registry::close() = ") + - OUString::number(static_cast<int>(err))), + "com.sun.star.registry.SimpleRegistry.close:" + " underlying Registry::close() = " + OUString::number(static_cast<int>(err)), static_cast< OWeakObject * >(this)); } } @@ -905,9 +874,8 @@ void SimpleRegistry::destroy() RegError err = registry_.destroy(OUString()); if (err != RegError::NO_ERROR) { throw css::registry::InvalidRegistryException( - (("com.sun.star.registry.SimpleRegistry.destroy:" - " underlying Registry::destroy() = ") + - OUString::number(static_cast<int>(err))), + "com.sun.star.registry.SimpleRegistry.destroy:" + " underlying Registry::destroy() = " + OUString::number(static_cast<int>(err)), static_cast< OWeakObject * >(this)); } } @@ -919,9 +887,8 @@ css::uno::Reference< css::registry::XRegistryKey > SimpleRegistry::getRootKey() RegError err = registry_.openRootKey(root); if (err != RegError::NO_ERROR) { throw css::registry::InvalidRegistryException( - (("com.sun.star.registry.SimpleRegistry.getRootKey:" - " underlying Registry::getRootKey() = ") + - OUString::number(static_cast<int>(err))), + "com.sun.star.registry.SimpleRegistry.getRootKey:" + " underlying Registry::getRootKey() = " + OUString::number(static_cast<int>(err)), static_cast< OWeakObject * >(this)); } return new Key(this, root); @@ -953,9 +920,8 @@ void SimpleRegistry::mergeKey( static_cast< cppu::OWeakObject * >(this)); default: throw css::registry::InvalidRegistryException( - (("com.sun.star.registry.SimpleRegistry.mergeKey:" - " underlying Registry::getRootKey/mergeKey() = ") + - OUString::number(static_cast<int>(err))), + "com.sun.star.registry.SimpleRegistry.mergeKey:" + " underlying Registry::getRootKey/mergeKey() = " + OUString::number(static_cast<int>(err)), static_cast< OWeakObject * >(this)); } } diff --git a/stoc/source/typeconv/convert.cxx b/stoc/source/typeconv/convert.cxx index 37b87f217900..3cca24c8d1a1 100644 --- a/stoc/source/typeconv/convert.cxx +++ b/stoc/source/typeconv/convert.cxx @@ -535,13 +535,13 @@ Any SAL_CALL TypeConverter_Impl::convertTo( const Any& rVal, const Type& aDestTy if (!ifc || !ifc->is()) { throw CannotConvertException( - "value is no interface!", + "value is not interface", Reference< XInterface >(), aDestinationClass, FailReason::NO_SUCH_INTERFACE, 0 ); } if (! (aRet = (*ifc)->queryInterface(aDestType )).hasValue()) { throw CannotConvertException( - "value has no such interface!", + "value does not implement " + aDestType.getTypeName(), Reference< XInterface >(), aDestinationClass, FailReason::NO_SUCH_INTERFACE, 0 ); } break; @@ -740,7 +740,7 @@ Any TypeConverter_Impl::convertToSimpleType( const Any& rVal, TypeClass aDestina else { throw CannotConvertException( - "STRING has no boolean value!", + "STRING has no boolean value, " + aStr, Reference< XInterface >(), aDestinationClass, FailReason::IS_NOT_BOOL, 0 ); } } |