diff options
author | Noel Grandin <noelgrandin@gmail.com> | 2020-09-26 21:58:18 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-09-27 09:50:31 +0200 |
commit | 960252e129bb72e10790672a5650c0ce24e0f1e0 (patch) | |
tree | 2fbd8842a2dd3c1aa88656a83ccd975419985e74 | |
parent | e0ce9ec1a543d5cbb91d061db067847052bf9c7e (diff) |
improve some exception messages
Change-Id: Ifc5d940fbf77ae13071c299fb6168bdc55dc5c95
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103493
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r-- | comphelper/source/container/embeddedobjectcontainer.cxx | 2 | ||||
-rw-r--r-- | comphelper/source/misc/storagehelper.cxx | 2 | ||||
-rw-r--r-- | comphelper/source/streaming/memorystream.cxx | 4 | ||||
-rw-r--r-- | comphelper/source/streaming/seekableinput.cxx | 2 | ||||
-rw-r--r-- | io/source/TextInputStream/TextInputStream.cxx | 4 | ||||
-rw-r--r-- | io/source/acceptor/acc_pipe.cxx | 6 | ||||
-rw-r--r-- | io/source/connector/ctr_pipe.cxx | 6 | ||||
-rw-r--r-- | package/source/xstor/ocompinstream.cxx | 2 | ||||
-rw-r--r-- | package/source/xstor/ohierarchyholder.cxx | 4 | ||||
-rw-r--r-- | package/source/xstor/owriteablestream.cxx | 20 | ||||
-rw-r--r-- | package/source/xstor/switchpersistencestream.cxx | 2 |
11 files changed, 27 insertions, 27 deletions
diff --git a/comphelper/source/container/embeddedobjectcontainer.cxx b/comphelper/source/container/embeddedobjectcontainer.cxx index 92b93a1ff704..944a4dd5b25f 100644 --- a/comphelper/source/container/embeddedobjectcontainer.cxx +++ b/comphelper/source/container/embeddedobjectcontainer.cxx @@ -88,7 +88,7 @@ const uno::Reference < embed::XStorage >& EmbedImpl::GetReplacements() } if ( !mxImageStorage.is() ) - throw io::IOException(); + throw io::IOException("No ObjectReplacements"); return mxImageStorage; } diff --git a/comphelper/source/misc/storagehelper.cxx b/comphelper/source/misc/storagehelper.cxx index c5bff7559f6a..6f86a56484fb 100644 --- a/comphelper/source/misc/storagehelper.cxx +++ b/comphelper/source/misc/storagehelper.cxx @@ -218,7 +218,7 @@ void OStorageHelper::SetCommonStorageEncryptionData( { uno::Reference< embed::XEncryptionProtectedStorage > xEncrSet( xStorage, uno::UNO_QUERY ); if ( !xEncrSet.is() ) - throw io::IOException(); // TODO + throw io::IOException("no XEncryptionProtectedStorage"); // TODO if ( aEncryptionData.getLength() == 2 && aEncryptionData[0].Name == "GpgInfos" && diff --git a/comphelper/source/streaming/memorystream.cxx b/comphelper/source/streaming/memorystream.cxx index b275ac34b06e..b8ff86e03b17 100644 --- a/comphelper/source/streaming/memorystream.cxx +++ b/comphelper/source/streaming/memorystream.cxx @@ -124,7 +124,7 @@ Reference< XOutputStream > SAL_CALL UNOMemoryStream::getOutputStream( ) sal_Int32 SAL_CALL UNOMemoryStream::readBytes( Sequence< sal_Int8 >& aData, sal_Int32 nBytesToRead ) { if( nBytesToRead < 0 ) - throw IOException(); + throw IOException("nBytesToRead < 0"); nBytesToRead = std::min( nBytesToRead, available() ); aData.realloc( nBytesToRead ); @@ -149,7 +149,7 @@ sal_Int32 SAL_CALL UNOMemoryStream::readSomeBytes( Sequence< sal_Int8 >& aData, void SAL_CALL UNOMemoryStream::skipBytes( sal_Int32 nBytesToSkip ) { if( nBytesToSkip < 0 ) - throw IOException(); + throw IOException("nBytesToSkip < 0"); mnCursor += std::min( nBytesToSkip, available() ); } diff --git a/comphelper/source/streaming/seekableinput.cxx b/comphelper/source/streaming/seekableinput.cxx index e4f654043dc7..905e739e85a1 100644 --- a/comphelper/source/streaming/seekableinput.cxx +++ b/comphelper/source/streaming/seekableinput.cxx @@ -110,7 +110,7 @@ void OSeekableInputWrapper::PrepareCopy_Impl() } if ( !m_xCopyInput.is() ) - throw io::IOException(); + throw io::IOException("no m_xCopyInput"); } // XInputStream diff --git a/io/source/TextInputStream/TextInputStream.cxx b/io/source/TextInputStream/TextInputStream.cxx index 0c40aaa5935c..644db6fb3177 100644 --- a/io/source/TextInputStream/TextInputStream.cxx +++ b/io/source/TextInputStream/TextInputStream.cxx @@ -314,12 +314,12 @@ sal_Int32 OTextInputStream::implReadNext() } catch( NotConnectedException& ) { - throw IOException(); + throw IOException("Not connected"); //throw IOException( L"OTextInputStream::implReadString failed" ); } catch( BufferSizeExceededException& ) { - throw IOException(); + throw IOException("Buffer size exceeded"); } } diff --git a/io/source/acceptor/acc_pipe.cxx b/io/source/acceptor/acc_pipe.cxx index b06b0aa678bc..69f1cad79206 100644 --- a/io/source/acceptor/acc_pipe.cxx +++ b/io/source/acceptor/acc_pipe.cxx @@ -73,7 +73,7 @@ namespace io_acceptor { if( m_nStatus ) { - throw IOException(); + throw IOException("pipe already closed"); } if( aReadBytes.getLength() < nBytesToRead ) { @@ -93,11 +93,11 @@ namespace io_acceptor { if( m_nStatus ) { - throw IOException(); + throw IOException("pipe already closed"); } if( m_pipe.write( seq.getConstArray() , seq.getLength() ) != seq.getLength() ) { - throw IOException(); + throw IOException("short write"); } } diff --git a/io/source/connector/ctr_pipe.cxx b/io/source/connector/ctr_pipe.cxx index 8d66dea7b901..5ee0b70bc970 100644 --- a/io/source/connector/ctr_pipe.cxx +++ b/io/source/connector/ctr_pipe.cxx @@ -51,7 +51,7 @@ namespace stoc_connector { { if( m_nStatus ) { - throw IOException(); + throw IOException("pipe already closed"); } if( aReadBytes.getLength() != nBytesToRead ) { @@ -65,11 +65,11 @@ namespace stoc_connector { { if( m_nStatus ) { - throw IOException(); + throw IOException("pipe already closed"); } if( m_pipe.write( seq.getConstArray() , seq.getLength() ) != seq.getLength() ) { - throw IOException(); + throw IOException("short write"); } } diff --git a/package/source/xstor/ocompinstream.cxx b/package/source/xstor/ocompinstream.cxx index 8f15962d3bf0..17092d9a54cd 100644 --- a/package/source/xstor/ocompinstream.cxx +++ b/package/source/xstor/ocompinstream.cxx @@ -413,7 +413,7 @@ uno::Sequence< uno::Sequence< beans::StringPair > > SAL_CALL OInputCompStream::g return aResult; } - throw io::IOException(); // the relations info could not be read + throw io::IOException("relations info could not be read"); // the relations info could not be read } void SAL_CALL OInputCompStream::insertRelationshipByID( const OUString& /*sID*/, const uno::Sequence< beans::StringPair >& /*aEntry*/, sal_Bool /*bReplace*/ ) diff --git a/package/source/xstor/ohierarchyholder.cxx b/package/source/xstor/ohierarchyholder.cxx index 58ec912869a2..e2f629fa809a 100644 --- a/package/source/xstor/ohierarchyholder.cxx +++ b/package/source/xstor/ohierarchyholder.cxx @@ -40,7 +40,7 @@ uno::Reference< embed::XExtendedStorageStream > OHierarchyHolder_Impl::GetStream uno::Reference< embed::XStorage > xOwnStor( m_xWeakOwnStorage.get(), uno::UNO_QUERY_THROW ); if ( !( nStorageMode & embed::ElementModes::WRITE ) && ( nStreamMode & embed::ElementModes::WRITE ) ) - throw io::IOException(); + throw io::IOException("invalid storage/stream mode combo"); uno::Reference< embed::XExtendedStorageStream > xResult = m_xChild->GetStreamHierarchically( nStorageMode, aListPath, nStreamMode, aEncryptionData ); @@ -82,7 +82,7 @@ uno::Reference< embed::XExtendedStorageStream > OHierarchyElement_Impl::GetStrea ::osl::MutexGuard aGuard( m_aMutex ); if ( !( nStorageMode & embed::ElementModes::WRITE ) && ( nStreamMode & embed::ElementModes::WRITE ) ) - throw io::IOException(); + throw io::IOException("invalid storage/stream mode combo"); if ( aListPath.empty() ) throw uno::RuntimeException(); diff --git a/package/source/xstor/owriteablestream.cxx b/package/source/xstor/owriteablestream.cxx index ac97214b7a1e..408003386ea2 100644 --- a/package/source/xstor/owriteablestream.cxx +++ b/package/source/xstor/owriteablestream.cxx @@ -119,10 +119,10 @@ void SetEncryptionKeyProperty_Impl( const uno::Reference< beans::XPropertySet >& try { xPropertySet->setPropertyValue( STORAGE_ENCRYPTION_KEYS_PROPERTY, uno::makeAny( aKey ) ); } - catch ( const uno::Exception& ) + catch ( const uno::Exception& ex ) { TOOLS_WARN_EXCEPTION( "package.xstor", "Can't write encryption related properties"); - throw io::IOException(); // TODO + throw io::IOException(ex.Message); // TODO } } @@ -135,10 +135,10 @@ uno::Any GetEncryptionKeyProperty_Impl( const uno::Reference< beans::XPropertySe try { return xPropertySet->getPropertyValue(STORAGE_ENCRYPTION_KEYS_PROPERTY); } - catch ( const uno::Exception& ) + catch ( const uno::Exception& ex ) { TOOLS_WARN_EXCEPTION( "package.xstor", "Can't get encryption related properties"); - throw io::IOException(); // TODO + throw io::IOException(ex.Message); // TODO } } @@ -503,7 +503,7 @@ OUString const & OWriteStream_Impl::GetFilledTempFileIfNo( const uno::Reference< uno::Reference< io::XOutputStream > xTempOutStream = xTempAccess->openFileWrite( aTempURL ); if ( !xTempOutStream.is() ) - throw io::IOException(); // TODO: + throw io::IOException("no temp stream"); // TODO: // the current position of the original stream should be still OK, copy further ::comphelper::OStorageHelper::CopyInputToOutput( xStream, xTempOutStream ); xTempOutStream->closeOutput(); @@ -579,7 +579,7 @@ OUString const & OWriteStream_Impl::FillTempGetFileName() uno::Reference< io::XOutputStream > xTempOutStream = xTempAccess->openFileWrite( m_aTempURL ); if ( !xTempOutStream.is() ) - throw io::IOException(); // TODO: + throw io::IOException("no temp stream"); // TODO: // copy stream contents to the file xTempOutStream->writeBytes( aData ); @@ -641,7 +641,7 @@ uno::Reference< io::XStream > OWriteStream_Impl::GetTempFileAsStream() // in case the stream can not be open // an exception should be thrown if ( !xTempStream.is() ) - throw io::IOException(); //TODO: + throw io::IOException("no temp stream"); //TODO: return xTempStream; } @@ -695,7 +695,7 @@ void OWriteStream_Impl::InsertStreamDirectly( const uno::Reference< io::XInputSt SAL_WARN_IF( !m_xPackageStream.is(), "package.xstor", "No package stream is set!" ); if ( m_bHasDataToFlush ) - throw io::IOException(); + throw io::IOException("m_bHasDataToFlush==true"); OSL_ENSURE( m_aTempURL.isEmpty() && !m_xCacheStream.is(), "The temporary must not exist!" ); @@ -1169,11 +1169,11 @@ uno::Reference< io::XStream > OWriteStream_Impl::GetStream( sal_Int32 nStreamMod SetEncryptionKeyProperty_Impl( xPropertySet, uno::Sequence< beans::NamedValue >() ); throw; } - catch ( const uno::Exception& ) + catch ( const uno::Exception& ex ) { TOOLS_WARN_EXCEPTION( "package.xstor", "Can't write encryption related properties"); SetEncryptionKeyProperty_Impl( xPropertySet, uno::Sequence< beans::NamedValue >() ); - throw io::IOException(); // TODO: + throw io::IOException(ex.Message); // TODO: } } diff --git a/package/source/xstor/switchpersistencestream.cxx b/package/source/xstor/switchpersistencestream.cxx index 7eac83cbf708..459f498fb98b 100644 --- a/package/source/xstor/switchpersistencestream.cxx +++ b/package/source/xstor/switchpersistencestream.cxx @@ -164,7 +164,7 @@ void SwitchablePersistenceStream::CopyAndSwitchPersistenceTo( const uno::Referen // the provided stream must be empty xTargetSeek.set( xTargetStream, uno::UNO_QUERY_THROW ); if ( xTargetSeek->getLength() ) - throw io::IOException(); + throw io::IOException("provided stream not empty"); } uno::Reference< io::XTruncate > xTargetTruncate( xTargetStream, uno::UNO_QUERY_THROW ); |