summaryrefslogtreecommitdiff
path: root/dbaccess/source
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2023-10-12 22:02:15 +0300
committerMike Kaganski <mike.kaganski@collabora.com>2023-10-14 15:37:17 +0200
commit176e8cf09a527438ec9b2b20ba2df23fa45226bc (patch)
tree76897d74143771a9ee9249c49bbe91da9ffa0433 /dbaccess/source
parent328d6aae9e2b7a73f6672800629230f5b46d15b1 (diff)
Use exception ctors, instead of setting members later
Avoids overwriting source location in message Change-Id: Ia0290c7dd1ab3ea1357712a27ecab75c7b583dd4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157893 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'dbaccess/source')
-rw-r--r--dbaccess/source/core/dataaccess/databasecontext.cxx5
-rw-r--r--dbaccess/source/core/dataaccess/datasource.cxx6
-rw-r--r--dbaccess/source/core/dataaccess/documentdefinition.cxx4
-rw-r--r--dbaccess/source/ui/app/AppController.cxx7
-rw-r--r--dbaccess/source/ui/dlg/dbwizsetup.cxx15
-rw-r--r--dbaccess/source/ui/dlg/sqlmessage.cxx7
-rw-r--r--dbaccess/source/ui/misc/WCopyTable.cxx3
-rw-r--r--dbaccess/source/ui/misc/datasourceconnector.cxx9
-rw-r--r--dbaccess/source/ui/misc/defaultobjectnamecheck.cxx3
-rw-r--r--dbaccess/source/ui/misc/linkeddocuments.cxx11
-rw-r--r--dbaccess/source/ui/querydesign/querycontroller.cxx8
-rw-r--r--dbaccess/source/ui/tabledesign/TableController.cxx8
-rw-r--r--dbaccess/source/ui/uno/copytablewizard.cxx16
13 files changed, 36 insertions, 66 deletions
diff --git a/dbaccess/source/core/dataaccess/databasecontext.cxx b/dbaccess/source/core/dataaccess/databasecontext.cxx
index 5677b5fe316f..a94560f1b0c4 100644
--- a/dbaccess/source/core/dataaccess/databasecontext.cxx
+++ b/dbaccess/source/core/dataaccess/databasecontext.cxx
@@ -307,8 +307,9 @@ Reference< XInterface > ODatabaseContext::loadObjectFromURL(const OUString& _rNa
OUString sErrorMessage( DBA_RES( RID_STR_FILE_DOES_NOT_EXIST ) );
::svt::OFileNotation aTransformer( _sURL );
- SQLException aError;
- aError.Message = sErrorMessage.replaceAll( "$file$", aTransformer.get( ::svt::OFileNotation::N_SYSTEM ) );
+ SQLException aError(sErrorMessage.replaceAll(
+ "$file$", aTransformer.get(::svt::OFileNotation::N_SYSTEM)),
+ {}, {}, 0, {});
throw WrappedTargetException( _sURL, *this, Any( aError ) );
}
diff --git a/dbaccess/source/core/dataaccess/datasource.cxx b/dbaccess/source/core/dataaccess/datasource.cxx
index 91959366aebf..e2c02d49c818 100644
--- a/dbaccess/source/core/dataaccess/datasource.cxx
+++ b/dbaccess/source/core/dataaccess/datasource.cxx
@@ -766,9 +766,9 @@ Reference< XConnection > ODatabaseSource::buildLowLevelConnection(const OUString
OUString sMessage = DBA_RES(pExceptionMessageId)
.replaceAll("$name$", m_pImpl->m_sConnectURL);
- SQLContext aContext;
- aContext.Message = DBA_RES(RID_STR_CONNECTION_REQUEST).
- replaceFirst("$name$", m_pImpl->m_sConnectURL);
+ SQLContext aContext(
+ DBA_RES(RID_STR_CONNECTION_REQUEST).replaceFirst("$name$", m_pImpl->m_sConnectURL),
+ {}, {}, 0, {}, {});
throwGenericSQLException( sMessage, static_cast< XDataSource* >( this ), Any( aContext ) );
}
diff --git a/dbaccess/source/core/dataaccess/documentdefinition.cxx b/dbaccess/source/core/dataaccess/documentdefinition.cxx
index 242cfd5c9e1c..227bde4cde1b 100644
--- a/dbaccess/source/core/dataaccess/documentdefinition.cxx
+++ b/dbaccess/source/core/dataaccess/documentdefinition.cxx
@@ -1566,9 +1566,7 @@ void ODocumentDefinition::loadEmbeddedObject( const Reference< XConnection >& i_
Reference< XEnumeration > xEnumDrivers = xEnumAccess->createContentEnumeration(sReportEngineServiceName);
if ( !xEnumDrivers.is() || !xEnumDrivers->hasMoreElements() )
{
- css::io::WrongFormatException aWFE;
- aWFE.Message = DBA_RES( RID_STR_MISSING_EXTENSION );
- throw aWFE;
+ throw css::io::WrongFormatException(DBA_RES(RID_STR_MISSING_EXTENSION));
}
}
if ( !aClassID.hasElements() )
diff --git a/dbaccess/source/ui/app/AppController.cxx b/dbaccess/source/ui/app/AppController.cxx
index ad18bff5892c..f9b818db663f 100644
--- a/dbaccess/source/ui/app/AppController.cxx
+++ b/dbaccess/source/ui/app/AppController.cxx
@@ -2520,11 +2520,8 @@ void OApplicationController::OnFirstControllerConnected()
if ( Reference< XStorable >( m_xModel, UNO_QUERY_THROW )->isReadonly() )
return;
- SQLWarning aWarning;
- aWarning.Message = DBA_RES(STR_SUB_DOCS_WITH_SCRIPTS);
- SQLException aDetail;
- aDetail.Message = DBA_RES(STR_SUB_DOCS_WITH_SCRIPTS_DETAIL);
- aWarning.NextException <<= aDetail;
+ SQLException aDetail(DBA_RES(STR_SUB_DOCS_WITH_SCRIPTS_DETAIL), {}, {}, 0, {});
+ SQLWarning aWarning(DBA_RES(STR_SUB_DOCS_WITH_SCRIPTS), {}, {}, 0, css::uno::Any(aDetail));
Reference< XExecutableDialog > xDialog = ErrorMessageDialog::create( getORB(), "", nullptr, Any( aWarning ) );
xDialog->execute();
diff --git a/dbaccess/source/ui/dlg/dbwizsetup.cxx b/dbaccess/source/ui/dlg/dbwizsetup.cxx
index 69662a17bcc6..720892e2a015 100644
--- a/dbaccess/source/ui/dlg/dbwizsetup.cxx
+++ b/dbaccess/source/ui/dlg/dbwizsetup.cxx
@@ -702,15 +702,12 @@ bool ODbTypeWizDialogSetup::SaveDatabaseDocument()
{
if ( !lcl_handle( xHandler, aError ) )
{
- InteractiveIOException aRequest;
- aRequest.Classification = InteractionClassification_ERROR;
- if ( aError.isExtractableTo( ::cppu::UnoType< IOException >::get() ) )
- // assume saving the document failed
- aRequest.Code = IOErrorCode_CANT_WRITE;
- else
- aRequest.Code = IOErrorCode_GENERAL;
- aRequest.Message = e.Message;
- aRequest.Context = e.Context;
+ css::ucb::IOErrorCode code
+ = aError.isExtractableTo(::cppu::UnoType<IOException>::get())
+ ? IOErrorCode_CANT_WRITE // assume saving the document failed
+ : IOErrorCode_GENERAL;
+ InteractiveIOException aRequest(e.Message, e.Context,
+ InteractionClassification_ERROR, code);
lcl_handle( xHandler, Any( aRequest ) );
}
}
diff --git a/dbaccess/source/ui/dlg/sqlmessage.cxx b/dbaccess/source/ui/dlg/sqlmessage.cxx
index b54bc8280839..e5cd612c282c 100644
--- a/dbaccess/source/ui/dlg/sqlmessage.cxx
+++ b/dbaccess/source/ui/dlg/sqlmessage.cxx
@@ -565,11 +565,10 @@ OSQLMessageBox::OSQLMessageBox(weld::Window* pParent, const SQLExceptionInfo& rE
OSQLMessageBox::OSQLMessageBox(weld::Window* pParent, const OUString& rTitle, const OUString& rMessage, MessBoxStyle nStyle, MessageType eType, const ::dbtools::SQLExceptionInfo* pAdditionalErrorInfo )
{
- SQLContext aError;
- aError.Message = rTitle;
- aError.Details = rMessage;
+ css::uno::Any next;
if (pAdditionalErrorInfo)
- aError.NextException = pAdditionalErrorInfo->get();
+ next = pAdditionalErrorInfo->get();
+ SQLContext aError(rTitle, {}, {}, 0, next, rMessage);
m_pImpl.reset(new SQLMessageBox_Impl(SQLExceptionInfo(aError)));
diff --git a/dbaccess/source/ui/misc/WCopyTable.cxx b/dbaccess/source/ui/misc/WCopyTable.cxx
index 40b8c0edd4c8..8cfe9ace02f2 100644
--- a/dbaccess/source/ui/misc/WCopyTable.cxx
+++ b/dbaccess/source/ui/misc/WCopyTable.cxx
@@ -842,8 +842,7 @@ IMPL_LINK_NOARG(OCopyTableWizard, ImplOKHdl, weld::Button&, void)
{
OUString sMsg(DBA_RES(STR_TABLEDESIGN_NO_PRIM_KEY));
- SQLContext aError;
- aError.Message = sMsg;
+ SQLContext aError(sMsg, {}, {}, 0, {}, {});
::rtl::Reference xRequest( new ::comphelper::OInteractionRequest( Any( aError ) ) );
::rtl::Reference xYes = new ::comphelper::OInteractionApprove;
xRequest->addContinuation( xYes );
diff --git a/dbaccess/source/ui/misc/datasourceconnector.cxx b/dbaccess/source/ui/misc/datasourceconnector.cxx
index 9025b24bb5f7..a170d02963f9 100644
--- a/dbaccess/source/ui/misc/datasourceconnector.cxx
+++ b/dbaccess/source/ui/misc/datasourceconnector.cxx
@@ -159,9 +159,7 @@ namespace dbaui
sMessage = sMessage.replaceFirst( "$buttontext$", GetStandardText( StandardButtonType::More ) );
sMessage = removeMnemonicFromString( sMessage );
- SQLWarning aContext;
- aContext.Message = sMessage;
- aContext.NextException = aWarnings;
+ SQLWarning aContext(sMessage, {}, {}, 0, aWarnings);
aInfo = aContext;
}
xConnectionWarnings->clearWarnings();
@@ -176,10 +174,7 @@ namespace dbaui
{
if ( !m_sContextInformation.isEmpty() )
{
- SQLException aError;
- aError.Message = m_sContextInformation;
- aError.NextException = aInfo.get();
-
+ SQLException aError(m_sContextInformation, {}, {}, 0, aInfo.get());
aInfo = aError;
}
}
diff --git a/dbaccess/source/ui/misc/defaultobjectnamecheck.cxx b/dbaccess/source/ui/misc/defaultobjectnamecheck.cxx
index 960219223051..cc44de2bdee0 100644
--- a/dbaccess/source/ui/misc/defaultobjectnamecheck.cxx
+++ b/dbaccess/source/ui/misc/defaultobjectnamecheck.cxx
@@ -58,9 +58,8 @@ namespace dbaui
{
void lcl_fillNameExistsError( std::u16string_view _rObjectName, SQLExceptionInfo& _out_rErrorToDisplay )
{
- SQLException aError;
OUString sErrorMessage = DBA_RES(STR_NAMED_OBJECT_ALREADY_EXISTS);
- aError.Message = sErrorMessage.replaceAll("$#$", _rObjectName);
+ SQLException aError(sErrorMessage.replaceAll("$#$", _rObjectName), {}, {}, 0, {});
_out_rErrorToDisplay = aError;
}
diff --git a/dbaccess/source/ui/misc/linkeddocuments.cxx b/dbaccess/source/ui/misc/linkeddocuments.cxx
index a08f90cc3425..dff938e3766b 100644
--- a/dbaccess/source/ui/misc/linkeddocuments.cxx
+++ b/dbaccess/source/ui/misc/linkeddocuments.cxx
@@ -303,16 +303,13 @@ namespace dbaui
OUString sMessage = DBA_RES(STR_COULDNOTOPEN_LINKEDDOC);
sMessage = sMessage.replaceFirst("$file$",_rLinkName);
- css::sdbc::SQLException aSQLException;
- aSQLException.Message = sMessage;
+ css::sdbc::SQLException aSQLException(sMessage, {}, {}, 0, {});
aInfo = dbtools::SQLExceptionInfo(aSQLException);
}
}
catch(const css::io::WrongFormatException &e)
{
- css::sdbc::SQLException aSQLException;
- aSQLException.Message = e.Message;
- aSQLException.Context = e.Context;
+ css::sdbc::SQLException aSQLException(e.Message, e.Context, {}, 0, {});
aInfo = dbtools::SQLExceptionInfo(aSQLException);
// more like a hack, insert an empty message
@@ -330,9 +327,7 @@ namespace dbaui
css::sdbc::SQLException a;
if ( !(aAny >>= a) || (a.ErrorCode != dbtools::ParameterInteractionCancelled) )
{
- css::sdbc::SQLException aSQLException;
- aSQLException.Message = e.Message;
- aSQLException.Context = e.Context;
+ css::sdbc::SQLException aSQLException(e.Message, e.Context, {}, 0, {});
aInfo = dbtools::SQLExceptionInfo(aSQLException);
// more like a hack, insert an empty message
diff --git a/dbaccess/source/ui/querydesign/querycontroller.cxx b/dbaccess/source/ui/querydesign/querycontroller.cxx
index 38caed31a79f..49f1b4e02be5 100644
--- a/dbaccess/source/ui/querydesign/querycontroller.cxx
+++ b/dbaccess/source/ui/querydesign/querycontroller.cxx
@@ -614,11 +614,9 @@ void OQueryController::Execute(sal_uInt16 _nId, const Sequence< PropertyValue >&
void OQueryController::impl_showAutoSQLViewError( const css::uno::Any& _rErrorDetails )
{
- SQLContext aErrorContext;
- aErrorContext.Message = lcl_getObjectResourceString( STR_ERROR_PARSING_STATEMENT, m_nCommandType );
- aErrorContext.Context = *this;
- aErrorContext.Details = lcl_getObjectResourceString( STR_INFO_OPENING_IN_SQL_VIEW, m_nCommandType );
- aErrorContext.NextException = _rErrorDetails;
+ SQLContext aErrorContext(
+ lcl_getObjectResourceString(STR_ERROR_PARSING_STATEMENT, m_nCommandType), *this, {}, 0,
+ _rErrorDetails, lcl_getObjectResourceString(STR_INFO_OPENING_IN_SQL_VIEW, m_nCommandType));
showError( aErrorContext );
}
diff --git a/dbaccess/source/ui/tabledesign/TableController.cxx b/dbaccess/source/ui/tabledesign/TableController.cxx
index db2fcf48fbbf..7e13ba566bb2 100644
--- a/dbaccess/source/ui/tabledesign/TableController.cxx
+++ b/dbaccess/source/ui/tabledesign/TableController.cxx
@@ -1164,15 +1164,11 @@ void OTableController::alterColumns()
}
catch (const SQLException&)
{
+ const auto caughtException = ::cppu::getCaughtException();
OUString sError( DBA_RES( STR_TABLEDESIGN_COULD_NOT_DROP_COL ) );
sError = sError.replaceFirst( "$column$", rColumnName );
- SQLException aNewException;
- aNewException.Message = sError;
- aNewException.SQLState = "S1000";
- aNewException.NextException = ::cppu::getCaughtException();
-
- throw aNewException;
+ throw SQLException(sError, {}, "S1000", 0, caughtException);
}
}
}
diff --git a/dbaccess/source/ui/uno/copytablewizard.cxx b/dbaccess/source/ui/uno/copytablewizard.cxx
index 85000f2dc9f8..b885b3e481f4 100644
--- a/dbaccess/source/ui/uno/copytablewizard.cxx
+++ b/dbaccess/source/ui/uno/copytablewizard.cxx
@@ -1011,24 +1011,20 @@ bool CopyTableWizard::impl_processCopyError_nothrow( const CopyTableRowEvent& _r
try
{
- SQLContext aError;
- aError.Context = *this;
- aError.Message = DBA_RES(STR_ERROR_OCCURRED_WHILE_COPYING);
-
+ css::uno::Any next;
::dbtools::SQLExceptionInfo aInfo( _rEvent.Error );
if ( aInfo.isValid() )
- aError.NextException = _rEvent.Error;
+ next = _rEvent.Error;
else
{
// a non-SQL exception happened
Exception aException;
OSL_VERIFY( _rEvent.Error >>= aException );
- SQLContext aContext;
- aContext.Context = aException.Context;
- aContext.Message = aException.Message;
- aContext.Details = _rEvent.Error.getValueTypeName();
- aError.NextException <<= aContext;
+ SQLContext aContext(aException.Message, aException.Context, {}, 0, {},
+ _rEvent.Error.getValueTypeName());
+ next <<= aContext;
}
+ SQLContext aError(DBA_RES(STR_ERROR_OCCURRED_WHILE_COPYING), *this, {}, 0, next, {});
::rtl::Reference< ::comphelper::OInteractionRequest > xRequest( new ::comphelper::OInteractionRequest( Any( aError ) ) );