diff options
author | Caolán McNamara <caolanm@redhat.com> | 2021-09-24 10:31:09 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2021-09-24 13:20:19 +0200 |
commit | 38b907c8bc1cd2cfc3f57abd97c5b2befb4a6a3d (patch) | |
tree | 00f2d91204269575deea5ec1663248da50f54cba /connectivity/source/commontools/dbexception.cxx | |
parent | 66636097f0464beffa678e0898bf379718494c10 (diff) |
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@redhat.com>
Diffstat (limited to 'connectivity/source/commontools/dbexception.cxx')
-rw-r--r-- | connectivity/source/commontools/dbexception.cxx | 19 |
1 files changed, 7 insertions, 12 deletions
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 { |