connectivity/source/parse/sqliterator.cxx | 12 +++++++----- include/connectivity/sqliterator.hxx | 7 ++++--- 2 files changed, 11 insertions(+), 8 deletions(-)
New commits: commit bc059c08d86ccdeca4f340078b0de39053bc0888 Author: Noel Grandin <[email protected]> AuthorDate: Wed May 13 11:02:41 2020 +0200 Commit: Noel Grandin <[email protected]> CommitDate: Wed May 13 14:06:49 2020 +0200 use std::optional for this error field otherwise when I add source/line to the uno::Exception in an upcoming change, the message becomes non-empty, and hasErrors() return true. I note that we throw SQLException in lots of places without a message, so it is possible that this change will cause us to notice errors we previously missed. Change-Id: Idf7c5b5143e20c992d8d7550043aa2ed875c78b1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94108 Tested-by: Jenkins Reviewed-by: Noel Grandin <[email protected]> diff --git a/connectivity/source/parse/sqliterator.cxx b/connectivity/source/parse/sqliterator.cxx index 7af9dc9ab9ee..ba3f274e65ef 100644 --- a/connectivity/source/parse/sqliterator.cxx +++ b/connectivity/source/parse/sqliterator.cxx @@ -38,6 +38,7 @@ #include <connectivity/dbmetadata.hxx> #include <com/sun/star/sdb/SQLFilterOperator.hpp> #include <sal/log.hxx> +#include <tools/diagnose_ex.h> #include <iterator> #include <memory> @@ -209,7 +210,7 @@ void OSQLParseTreeIterator::setParseTree(const OSQLParseNode * pNewParseTree) if ( !m_pImpl->m_xTableContainer.is() ) return; - m_aErrors = SQLException(); + m_xErrors.reset(); // Determine statement type ... @@ -1468,7 +1469,7 @@ void OSQLParseTreeIterator::traverseAll() void OSQLParseTreeIterator::impl_traverse( TraversalParts _nIncludeMask ) { // resets our errors - m_aErrors = css::sdbc::SQLException(); + m_xErrors.reset(); m_pImpl->m_nIncludeMask = _nIncludeMask; @@ -2006,15 +2007,16 @@ void OSQLParseTreeIterator::impl_appendError( IParseContext::ErrorCode _eError, void OSQLParseTreeIterator::impl_appendError( const SQLException& _rError ) { - if ( !m_aErrors.Message.isEmpty() ) + SAL_WARN("connectivity.parse", "Adding error " << exceptionToString(Any(_rError))); + if ( m_xErrors ) { - SQLException* pErrorChain = &m_aErrors; + SQLException* pErrorChain = &*m_xErrors; while ( pErrorChain->NextException.hasValue() ) pErrorChain = static_cast< SQLException* >( pErrorChain->NextException.pData ); pErrorChain->NextException <<= _rError; } else - m_aErrors = _rError; + m_xErrors = _rError; } sal_Int32 OSQLParseTreeIterator::getFunctionReturnType(const OSQLParseNode* _pNode ) diff --git a/include/connectivity/sqliterator.hxx b/include/connectivity/sqliterator.hxx index f77df204d52c..e4f0450ea4bb 100644 --- a/include/connectivity/sqliterator.hxx +++ b/include/connectivity/sqliterator.hxx @@ -27,6 +27,7 @@ #include <rtl/ref.hxx> #include <memory> +#include <optional> #include <vector> #include <o3tl/typed_flags_set.hxx> @@ -78,7 +79,7 @@ namespace connectivity class OOO_DLLPUBLIC_DBTOOLS OSQLParseTreeIterator final { private: - css::sdbc::SQLException m_aErrors; // contains the error while iterating through the statement + std::optional<css::sdbc::SQLException> m_xErrors; // contains the error while iterating through the statement const OSQLParseNode* m_pParseTree; // current ParseTree const OSQLParser& m_rParser; // if set used for general error messages from the context OSQLStatementType m_eStatementType; @@ -178,8 +179,8 @@ namespace connectivity The returned object contains a chain (via SQLException::NextException) of SQLExceptions. */ - const css::sdbc::SQLException& getErrors() const { return m_aErrors; } - bool hasErrors() const { return !m_aErrors.Message.isEmpty(); } + const css::sdbc::SQLException& getErrors() const { return *m_xErrors; } + bool hasErrors() const { return bool(m_xErrors); } // statement type (already set in setParseTree): OSQLStatementType getStatementType() const { return m_eStatementType; } _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
