comphelper/source/xml/ofopxmlhelper.cxx |   11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

New commits:
commit 74dacdca49304b3acef686de9c6e4bdda3643902
Author:     Mohamed_Ali <[email protected]>
AuthorDate: Thu Jan 9 23:53:41 2025 +0200
Commit:     Stephan Bergmann <[email protected]>
CommitDate: Fri Jan 10 08:10:02 2025 +0100

    tdf#42982 Improve Error Messages with RuntimeException in UNO API
    
    Change-Id: Ib1b84374ae87d2565bf4557cc4bc6153c12978cd
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/177150
    Reviewed-by: Stephan Bergmann <[email protected]>
    Tested-by: Jenkins

diff --git a/comphelper/source/xml/ofopxmlhelper.cxx 
b/comphelper/source/xml/ofopxmlhelper.cxx
index c678d7841c0b..2fe9e5464237 100644
--- a/comphelper/source/xml/ofopxmlhelper.cxx
+++ b/comphelper/source/xml/ofopxmlhelper.cxx
@@ -134,7 +134,7 @@ void WriteRelationsInfoSequence(
         const uno::Reference< uno::XComponentContext >& rContext )
 {
     if ( !xOutStream.is() )
-        throw uno::RuntimeException();
+        throw uno::RuntimeException("Invalid output stream");
 
     uno::Reference< css::xml::sax::XWriter > xWriter = 
css::xml::sax::Writer::create(rContext);
 
@@ -187,7 +187,7 @@ void WriteContentSequence(
         const uno::Reference< uno::XComponentContext >& rContext )
 {
     if ( !xOutStream.is() )
-        throw uno::RuntimeException();
+        throw uno::RuntimeException("Invalid output stream");
 
     uno::Reference< css::xml::sax::XWriter > xWriter = 
css::xml::sax::Writer::create(rContext);
 
@@ -242,7 +242,8 @@ uno::Sequence< uno::Sequence< beans::StringPair > > 
ReadSequence_Impl(
         const uno::Reference< uno::XComponentContext >& rContext )
 {
     if ( !rContext.is() || !xInStream.is() || nFormat > FORMAT_MAX_ID )
-        throw uno::RuntimeException();
+        throw uno::RuntimeException("Invalid input stream or context");
+
 
     uno::Reference< css::xml::sax::XParser > xParser = 
css::xml::sax::Parser::create( rContext );
 
@@ -391,7 +392,7 @@ void SAL_CALL OFOPXMLHelper_Impl::startElement( const 
OUString& aName, const uno
                 m_aResultSeq.realloc( 2 );
 
             if ( m_aResultSeq.getLength() != 2 )
-                throw uno::RuntimeException();
+                throw uno::RuntimeException("m_aResultSeq already has elements 
and is not reallocated to 2.");
 
             auto pResultSeq = m_aResultSeq.getArray();
 
@@ -422,7 +423,7 @@ void SAL_CALL OFOPXMLHelper_Impl::startElement( const 
OUString& aName, const uno
                 m_aResultSeq.realloc( 2 );
 
             if ( m_aResultSeq.getLength() != 2 )
-                throw uno::RuntimeException();
+                throw uno::RuntimeException("m_aResultSeq already has elements 
and is not reallocated to 2.");
 
             auto pResultSeq = m_aResultSeq.getArray();
 

Reply via email to