diff options
author | Caolán McNamara <caolanm@redhat.com> | 2021-09-24 10:41:27 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2021-09-24 13:43:57 +0200 |
commit | fa89349b360945d726db0c5f85cd4ccb0822417f (patch) | |
tree | f58a010d79d4acf1ff46e58ef3a2dcb19c2de9a3 /connectivity | |
parent | b71079f6e145a8916e1bc7f198e7c445a7101dc8 (diff) |
make SQLExceptionInfo utilities available for external use
Change-Id: I6561fa433f6619d8de97983fa962f874cbf5b536
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122570
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'connectivity')
-rw-r--r-- | connectivity/source/commontools/dbexception.cxx | 71 |
1 files changed, 34 insertions, 37 deletions
diff --git a/connectivity/source/commontools/dbexception.cxx b/connectivity/source/commontools/dbexception.cxx index 17f54b8bcaad..e6663f7d188b 100644 --- a/connectivity/source/commontools/dbexception.cxx +++ b/connectivity/source/commontools/dbexception.cxx @@ -187,49 +187,46 @@ void SQLExceptionInfo::prepend( const OUString& _rErrorMessage ) m_eType = TYPE::SQLException; } -namespace +// create the to-be-appended exception +Any SQLExceptionInfo::createException(TYPE eType, const OUString& rErrorMessage, const OUString& rSQLState, const sal_Int32 nErrorCode) { - // create the to-be-appended exception - Any createException(SQLExceptionInfo::TYPE eType, const OUString& rErrorMessage, const OUString& rSQLState, const sal_Int32 nErrorCode) + Any aAppend; + switch (eType) { - Any aAppend; - switch (eType) - { - case SQLExceptionInfo::TYPE::SQLException: - aAppend <<= SQLException(); - break; - case SQLExceptionInfo::TYPE::SQLWarning: - aAppend <<= SQLWarning(); - break; - case SQLExceptionInfo::TYPE::SQLContext: - aAppend <<= SQLContext(); - break; - default: - TOOLS_WARN_EXCEPTION("connectivity.commontools", "SQLExceptionInfo::createException: invalid exception type: this will crash!"); - break; - } - - SQLException& pAppendException = const_cast<SQLException &>(*o3tl::forceAccess<SQLException>(aAppend)); - pAppendException.Message = rErrorMessage; - pAppendException.SQLState = rSQLState; - pAppendException.ErrorCode = nErrorCode; - - return aAppend; + case TYPE::SQLException: + aAppend <<= SQLException(); + break; + case TYPE::SQLWarning: + aAppend <<= SQLWarning(); + break; + case TYPE::SQLContext: + aAppend <<= SQLContext(); + break; + default: + TOOLS_WARN_EXCEPTION("connectivity.commontools", "SQLExceptionInfo::createException: invalid exception type: this will crash!"); + break; } - // find the end of the exception chain - SQLException* getLastException(SQLException* pLastException) + SQLException& pAppendException = const_cast<SQLException &>(*o3tl::forceAccess<SQLException>(aAppend)); + pAppendException.Message = rErrorMessage; + pAppendException.SQLState = rSQLState; + pAppendException.ErrorCode = nErrorCode; + + return aAppend; +} + +// find the end of the exception chain +SQLException* SQLExceptionInfo::getLastException(SQLException* pLastException) +{ + SQLException* pException = pLastException; + while (pException) { - SQLException* pException = pLastException; - while (pException) - { - pException = const_cast<SQLException*>(o3tl::tryAccess<SQLException>(pException->NextException)); - if (!pException) - break; - pLastException = pException; - } - return pLastException; + 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 ) |