[Libreoffice-commits] core.git: connectivity/source

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Fri Sep 24 11:20:56 UTC 2021


 connectivity/source/commontools/dbexception.cxx |   19 +++++++------------
 1 file changed, 7 insertions(+), 12 deletions(-)

New commits:
commit 38b907c8bc1cd2cfc3f57abd97c5b2befb4a6a3d
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Fri Sep 24 10:31:09 2021 +0100
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Fri Sep 24 13:20:19 2021 +0200

    refactor getting the last exception of a SQLException chain
    
    Change-Id: Ia60766709e5093f5cc60d44697343e5a63f7ba03
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122568
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/connectivity/source/commontools/dbexception.cxx b/connectivity/source/commontools/dbexception.cxx
index 624999d8dd94..91ed140a2749 100644
--- a/connectivity/source/commontools/dbexception.cxx
+++ b/connectivity/source/commontools/dbexception.cxx
@@ -224,23 +224,18 @@ void SQLExceptionInfo::append( TYPE _eType, const OUString& _rErrorMessage, cons
     Any aAppend = createException(_eType, _rErrorMessage, _rSQLState, _nErrorCode);
 
     // find the end of the current chain
-    Any* pChainIterator = &m_aContent;
-    SQLException* pLastException = nullptr;
-    const Type& aSQLExceptionType( cppu::UnoType<SQLException>::get() );
-    while ( pChainIterator )
+    SQLException* pLastException = const_cast<SQLException*>(o3tl::tryAccess<SQLException>(m_aContent));
+    SQLException* pException = pLastException;
+    while (pException)
     {
-        if ( !pChainIterator->hasValue() )
+        pException = const_cast<SQLException*>(o3tl::tryAccess<SQLException>(pException->NextException));
+        if (!pException)
             break;
-
-        if ( !isAssignableFrom( aSQLExceptionType, pChainIterator->getValueType() ) )
-            break;
-
-        pLastException = const_cast< SQLException* >( o3tl::doAccess<SQLException>( *pChainIterator ) );
-        pChainIterator = &pLastException->NextException;
+        pLastException = pException;
     }
 
     // append
-    if ( pLastException )
+    if (pLastException)
         pLastException->NextException = aAppend;
     else
     {


More information about the Libreoffice-commits mailing list