diff options
author | Caolán McNamara <caolanm@redhat.com> | 2021-09-24 10:36:09 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2021-09-24 13:43:42 +0200 |
commit | b71079f6e145a8916e1bc7f198e7c445a7101dc8 (patch) | |
tree | 3aa19a0bed5e6e281ebd83925557bb99921e43f3 /connectivity | |
parent | 6db2d41f2bc085e249282644fd7d2b1c04338a8d (diff) |
split SQLExceptionInfo::append more
Change-Id: Id6dd8dfc3dc072f573e3a1a750428cb149be8e83
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122569
Tested-by: Caolán McNamara <caolanm@redhat.com>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'connectivity')
-rw-r--r-- | connectivity/source/commontools/dbexception.cxx | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/connectivity/source/commontools/dbexception.cxx b/connectivity/source/commontools/dbexception.cxx index 91ed140a2749..17f54b8bcaad 100644 --- a/connectivity/source/commontools/dbexception.cxx +++ b/connectivity/source/commontools/dbexception.cxx @@ -189,9 +189,9 @@ void SQLExceptionInfo::prepend( const OUString& _rErrorMessage ) namespace { + // create the to-be-appended exception Any createException(SQLExceptionInfo::TYPE eType, const OUString& rErrorMessage, const OUString& rSQLState, const sal_Int32 nErrorCode) { - // create the to-be-appended exception Any aAppend; switch (eType) { @@ -216,6 +216,20 @@ namespace return aAppend; } + + // find the end of the exception chain + SQLException* getLastException(SQLException* pLastException) + { + SQLException* pException = pLastException; + while (pException) + { + pException = const_cast<SQLException*>(o3tl::tryAccess<SQLException>(pException->NextException)); + if (!pException) + break; + pLastException = pException; + } + return pLastException; + } } void SQLExceptionInfo::append( TYPE _eType, const OUString& _rErrorMessage, const OUString& _rSQLState, const sal_Int32 _nErrorCode ) @@ -224,15 +238,7 @@ void SQLExceptionInfo::append( TYPE _eType, const OUString& _rErrorMessage, cons Any aAppend = createException(_eType, _rErrorMessage, _rSQLState, _nErrorCode); // find the end of the current chain - SQLException* pLastException = const_cast<SQLException*>(o3tl::tryAccess<SQLException>(m_aContent)); - SQLException* pException = pLastException; - while (pException) - { - pException = const_cast<SQLException*>(o3tl::tryAccess<SQLException>(pException->NextException)); - if (!pException) - break; - pLastException = pException; - } + SQLException* pLastException = getLastException(const_cast<SQLException*>(o3tl::tryAccess<SQLException>(m_aContent))); // append if (pLastException) |