diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2023-10-12 22:02:15 +0300 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2023-10-14 15:37:17 +0200 |
commit | 176e8cf09a527438ec9b2b20ba2df23fa45226bc (patch) | |
tree | 76897d74143771a9ee9249c49bbe91da9ffa0433 | |
parent | 328d6aae9e2b7a73f6672800629230f5b46d15b1 (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>
48 files changed, 157 insertions, 318 deletions
diff --git a/connectivity/source/commontools/dbexception.cxx b/connectivity/source/commontools/dbexception.cxx index 0f6fec238129..bc5a9be80804 100644 --- a/connectivity/source/commontools/dbexception.cxx +++ b/connectivity/source/commontools/dbexception.cxx @@ -66,8 +66,7 @@ SQLExceptionInfo::SQLExceptionInfo(const css::sdb::SQLContext& _rError) SQLExceptionInfo::SQLExceptionInfo( const OUString& _rSimpleErrorMessage ) { - SQLException aError; - aError.Message = _rSimpleErrorMessage; + SQLException aError(_rSimpleErrorMessage, {}, {}, 0, {}); m_aContent <<= aError; implDetermineType(); } @@ -177,11 +176,7 @@ SQLExceptionInfo::operator const css::sdb::SQLContext*() const void SQLExceptionInfo::prepend( const OUString& _rErrorMessage ) { - SQLException aException; - aException.Message = _rErrorMessage; - aException.ErrorCode = 0; - aException.SQLState = "S1000"; - aException.NextException = m_aContent; + SQLException aException(_rErrorMessage, {}, "S1000", 0, m_aContent); m_aContent <<= aException; m_eType = TYPE::SQLException; @@ -194,24 +189,19 @@ Any SQLExceptionInfo::createException(TYPE eType, const OUString& rErrorMessage, switch (eType) { case TYPE::SQLException: - aAppend <<= SQLException(); + aAppend <<= SQLException(rErrorMessage, {}, rSQLState, nErrorCode, {}); break; case TYPE::SQLWarning: - aAppend <<= SQLWarning(); + aAppend <<= SQLWarning(rErrorMessage, {}, rSQLState, nErrorCode, {}); break; case TYPE::SQLContext: - aAppend <<= SQLContext(); + aAppend <<= SQLContext(rErrorMessage, {}, rSQLState, nErrorCode, {}, {}); 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; } diff --git a/connectivity/source/commontools/paramwrapper.cxx b/connectivity/source/commontools/paramwrapper.cxx index 9ab5293c2057..e25a3e7b4905 100644 --- a/connectivity/source/commontools/paramwrapper.cxx +++ b/connectivity/source/commontools/paramwrapper.cxx @@ -215,11 +215,7 @@ namespace dbtools::param } catch( SQLException& e ) { - WrappedTargetException aExceptionWrapper; - aExceptionWrapper.Context = e.Context; - aExceptionWrapper.Message = e.Message; - aExceptionWrapper.TargetException <<= e; - throw aExceptionWrapper; + throw WrappedTargetException(e.Message, e.Context, css::uno::Any(e)); } } else diff --git a/connectivity/source/drivers/calc/CConnection.cxx b/connectivity/source/drivers/calc/CConnection.cxx index 8d4a0c01ebc1..f4f1b409e2f5 100644 --- a/connectivity/source/drivers/calc/CConnection.cxx +++ b/connectivity/source/drivers/calc/CConnection.cxx @@ -142,12 +142,11 @@ Reference< XSpreadsheetDocument> const & OCalcConnection::acquireDoc() Exception aLoaderError; OSL_VERIFY( aLoaderException >>= aLoaderError ); - SQLException aDetailException; - aDetailException.Message = m_aResources.getResourceStringWithSubstitution( - STR_LOAD_FILE_ERROR_MESSAGE, - "$exception_type$", aLoaderException.getValueTypeName(), - "$error_message$", aLoaderError.Message - ); + SQLException aDetailException(m_aResources.getResourceStringWithSubstitution( + STR_LOAD_FILE_ERROR_MESSAGE, "$exception_type$", + aLoaderException.getValueTypeName(), + "$error_message$", aLoaderError.Message), + {}, {}, 0, {}); aErrorDetails <<= aDetailException; } diff --git a/connectivity/source/drivers/file/FConnection.cxx b/connectivity/source/drivers/file/FConnection.cxx index 90030abb51db..de93df897b23 100644 --- a/connectivity/source/drivers/file/FConnection.cxx +++ b/connectivity/source/drivers/file/FConnection.cxx @@ -413,17 +413,13 @@ const Sequence< sal_Int8 > & OConnection::getUnoTunnelId() void OConnection::throwUrlNotValid(const OUString & _rsUrl,const OUString & _rsMessage) { - SQLException aError; - aError.Message = getResources().getResourceStringWithSubstitution( - STR_NO_VALID_FILE_URL, - "$URL$", _rsUrl - ); - - aError.SQLState = "S1000"; - aError.ErrorCode = 0; - aError.Context = static_cast< XConnection* >(this); + XConnection* context = this; + css::uno::Any next; if (!_rsMessage.isEmpty()) - aError.NextException <<= SQLException(_rsMessage, aError.Context, OUString(), 0, Any()); + next <<= SQLException(_rsMessage, context, OUString(), 0, Any()); + SQLException aError( + getResources().getResourceStringWithSubstitution(STR_NO_VALID_FILE_URL, "$URL$", _rsUrl), + context, "S1000", 0, next); throw aError; } diff --git a/connectivity/source/drivers/jdbc/JConnection.cxx b/connectivity/source/drivers/jdbc/JConnection.cxx index cff6f8f4e45b..77d0ff38799b 100644 --- a/connectivity/source/drivers/jdbc/JConnection.cxx +++ b/connectivity/source/drivers/jdbc/JConnection.cxx @@ -524,12 +524,8 @@ Any SAL_CALL java_sql_Connection::getWarnings( ) SQLException aAsException( java_sql_SQLWarning( warn_base, *this ) ); // translate to warning - SQLWarning aWarning; - aWarning.Context = aAsException.Context; - aWarning.Message = aAsException.Message; - aWarning.SQLState = aAsException.SQLState; - aWarning.ErrorCode = aAsException.ErrorCode; - aWarning.NextException = aAsException.NextException; + SQLWarning aWarning(aAsException.Message, aAsException.Context, aAsException.SQLState, + aAsException.ErrorCode, aAsException.NextException); return Any( aWarning ); } diff --git a/connectivity/source/drivers/postgresql/pq_xtable.cxx b/connectivity/source/drivers/postgresql/pq_xtable.cxx index 4a659ffb9941..de8196f9fecd 100644 --- a/connectivity/source/drivers/postgresql/pq_xtable.cxx +++ b/connectivity/source/drivers/postgresql/pq_xtable.cxx @@ -190,8 +190,7 @@ void Table::rename( const OUString& newName ) } catch( css::sdbc::SQLException &e ) { - OUString buf( e.Message + "(NOTE: Only postgresql server >= V8.1 support changing a table's schema)" ); - e.Message = buf; + e.Message += "(NOTE: Only postgresql server >= V8.1 support changing a table's schema)"; throw; } diff --git a/connectivity/source/drivers/postgresql/pq_xview.cxx b/connectivity/source/drivers/postgresql/pq_xview.cxx index 2b8f61be708d..c2e936e9a314 100644 --- a/connectivity/source/drivers/postgresql/pq_xview.cxx +++ b/connectivity/source/drivers/postgresql/pq_xview.cxx @@ -126,8 +126,7 @@ void View::rename( const OUString& newName ) } catch( css::sdbc::SQLException &e ) { - OUString buf( e.Message + "(NOTE: Only postgresql server >= V8.1 support changing a table's schema)" ); - e.Message = buf; + e.Message += "(NOTE: Only postgresql server >= V8.1 support changing a table's schema)"; throw; } 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 ) ) ); diff --git a/extensions/source/abpilot/datasourcehandling.cxx b/extensions/source/abpilot/datasourcehandling.cxx index e3c0f5cb1548..fd5820fce1ee 100644 --- a/extensions/source/abpilot/datasourcehandling.cxx +++ b/extensions/source/abpilot/datasourcehandling.cxx @@ -558,10 +558,10 @@ namespace abp if ( aException.Message.isEmpty() ) { // prepend some context info - SQLContext aDetailedError; - aDetailedError.Message = compmodule::ModuleRes(RID_STR_NOCONNECTION); - aDetailedError.Details = compmodule::ModuleRes(RID_STR_PLEASECHECKSETTINGS); - aDetailedError.NextException = aError; + SQLContext aDetailedError(compmodule::ModuleRes(RID_STR_NOCONNECTION), // message + {}, {}, 0, + aError, // next exception + compmodule::ModuleRes(RID_STR_PLEASECHECKSETTINGS)); // details // handle (aka display) the new context info xInteractions->handle( new OInteractionRequest( Any( aDetailedError ) ) ); } diff --git a/extensions/source/dbpilots/controlwizard.cxx b/extensions/source/dbpilots/controlwizard.cxx index 95a3801573df..17ec948ed017 100644 --- a/extensions/source/dbpilots/controlwizard.cxx +++ b/extensions/source/dbpilots/controlwizard.cxx @@ -575,9 +575,8 @@ namespace dbp { // an SQLException (or derivee) was thrown ... // prepend an extra SQLContext explaining what we were doing - SQLContext aContext; - aContext.Message = compmodule::ModuleRes(RID_STR_COULDNOTOPENTABLE); - aContext.NextException = aSQLException; + SQLContext aContext(compmodule::ModuleRes(RID_STR_COULDNOTOPENTABLE), {}, {}, 0, + aSQLException, {}); // create an interaction handler to display this exception Reference< XInteractionHandler > xHandler = getInteractionHandler(m_xAssistant.get()); diff --git a/extensions/source/propctrlr/formcomponenthandler.cxx b/extensions/source/propctrlr/formcomponenthandler.cxx index 4265a8bc2dee..119f270e5d51 100644 --- a/extensions/source/propctrlr/formcomponenthandler.cxx +++ b/extensions/source/propctrlr/formcomponenthandler.cxx @@ -2422,9 +2422,7 @@ namespace pcr if ( aParser.GetProtocol() != INetProtocol::NotValid ) sDataSourceName = aParser.getBase( INetURLObject::LAST_SEGMENT, true, INetURLObject::DecodeMechanism::WithCharset ); OUString sInfo(PcrRes(RID_STR_UNABLETOCONNECT).replaceAll("$name$", sDataSourceName)); - SQLContext aContext; - aContext.Message = sInfo; - aContext.NextException = aError.get(); + SQLContext aContext(sInfo, {}, {}, 0, aError.get(), {}); impl_displaySQLError_nothrow( aContext ); } diff --git a/extensions/source/propctrlr/formlinkdialog.cxx b/extensions/source/propctrlr/formlinkdialog.cxx index 68143835edae..c46cc95cbe2b 100644 --- a/extensions/source/propctrlr/formlinkdialog.cxx +++ b/extensions/source/propctrlr/formlinkdialog.cxx @@ -414,9 +414,7 @@ namespace pcr sErrorMessage = sErrorMessage.replaceFirst("#", sCommand); } - SQLContext aContext; - aContext.Message = sErrorMessage; - aContext.NextException = aErrorInfo.get(); + SQLContext aContext(sErrorMessage, {}, {}, 0, aErrorInfo.get(), {}); ::dbtools::showError(aContext, m_xDialog->GetXWindow(), m_xContext); } diff --git a/forms/source/component/Filter.cxx b/forms/source/component/Filter.cxx index c59139d0f5d7..295d4af747c1 100644 --- a/forms/source/component/Filter.cxx +++ b/forms/source/component/Filter.cxx @@ -515,9 +515,7 @@ namespace frm if ( !aPredicateInput.normalizePredicateString( aNewText, m_xField, &sErrorMessage ) ) { // display the error and outta here - SQLContext aError; - aError.Message = ResourceManager::loadString(RID_STR_SYNTAXERROR); - aError.Details = sErrorMessage; + SQLContext aError(ResourceManager::loadString(RID_STR_SYNTAXERROR), {}, {}, 0, {}, sErrorMessage); displayException( aError ); return false; } diff --git a/forms/source/xforms/datatypes.cxx b/forms/source/xforms/datatypes.cxx index c2612f65f0ca..e2ad59e17700 100644 --- a/forms/source/xforms/datatypes.cxx +++ b/forms/source/xforms/datatypes.cxx @@ -243,10 +243,7 @@ namespace xforms OUString sErrorMessage; if ( !checkPropertySanity( _nHandle, _rConvertedValue, sErrorMessage ) ) { - IllegalArgumentException aException; - aException.Message = sErrorMessage; - aException.Context = *this; - throw aException; + throw IllegalArgumentException(sErrorMessage, *this, 0); } return true; diff --git a/pyuno/source/module/pyuno_runtime.cxx b/pyuno/source/module/pyuno_runtime.cxx index 799752fefee3..68b1ea508293 100644 --- a/pyuno/source/module/pyuno_runtime.cxx +++ b/pyuno/source/module/pyuno_runtime.cxx @@ -943,8 +943,7 @@ Any Runtime::extractUnoException( const PyRef & excType, const PyRef &excValue, { buf.append( ", no traceback available\n" ); } - RuntimeException e; - e.Message = buf.makeStringAndClear(); + RuntimeException e(buf.makeStringAndClear()); #if OSL_DEBUG_LEVEL > 0 fprintf( stderr, "Python exception: %s\n", OUStringToOString(e.Message, RTL_TEXTENCODING_UTF8).getStr() ); diff --git a/reportdesign/source/ui/report/ReportController.cxx b/reportdesign/source/ui/report/ReportController.cxx index bb869d7061e5..9c33e4437d2d 100644 --- a/reportdesign/source/ui/report/ReportController.cxx +++ b/reportdesign/source/ui/report/ReportController.cxx @@ -2851,9 +2851,7 @@ uno::Reference<frame::XModel> OReportController::executeReport() dbtools::SQLExceptionInfo aInfo; if ( !bEnabled ) { - sdb::SQLContext aFirstMessage; - OUString sInfo = RptResId( pErrorId ); - aFirstMessage.Message = sInfo; + sdb::SQLContext aFirstMessage(RptResId(pErrorId), {}, {}, 0, {}, {}); aInfo = aFirstMessage; if ( isEditable() ) { @@ -2898,29 +2896,25 @@ uno::Reference<frame::XModel> OReportController::executeReport() { uno::Any aCaughtException( ::cppu::getCaughtException() ); - // our first message says: we caught an exception - sdb::SQLContext aFirstMessage; - OUString sInfo(RptResId(RID_STR_CAUGHT_FOREIGN_EXCEPTION)); - sInfo = sInfo.replaceAll("$type$", aCaughtException.getValueTypeName()); - aFirstMessage.Message = sInfo; - - // our second message: the message of the exception we caught - sdbc::SQLException aSecondMessage; - aSecondMessage.Message = e.Message; - aSecondMessage.Context = e.Context; - // maybe our third message: the message which is wrapped in the exception we caught - sdbc::SQLException aThirdMessage; - lang::WrappedTargetException aWrapped; - if ( aCaughtException >>= aWrapped ) + css::uno::Any aOptThirdMessage; + if (lang::WrappedTargetException aWrapped; aCaughtException >>= aWrapped) { + sdbc::SQLException aThirdMessage; aThirdMessage.Message = aWrapped.Message; aThirdMessage.Context = aWrapped.Context; + if ( !aThirdMessage.Message.isEmpty() ) + aOptThirdMessage <<= aThirdMessage; } - if ( !aThirdMessage.Message.isEmpty() ) - aSecondMessage.NextException <<= aThirdMessage; - aFirstMessage.NextException <<= aSecondMessage; + + // our second message: the message of the exception we caught + sdbc::SQLException aSecondMessage(e.Message, e.Context, {}, 0, aOptThirdMessage); + + // our first message says: we caught an exception + OUString sInfo(RptResId(RID_STR_CAUGHT_FOREIGN_EXCEPTION)); + sInfo = sInfo.replaceAll("$type$", aCaughtException.getValueTypeName()); + sdb::SQLContext aFirstMessage(sInfo, {}, {}, 0, css::uno::Any(aSecondMessage), {}); aInfo = aFirstMessage; } diff --git a/sax/source/expatwrap/saxwriter.cxx b/sax/source/expatwrap/saxwriter.cxx index 180126684ea1..55608101faf5 100644 --- a/sax/source/expatwrap/saxwriter.cxx +++ b/sax/source/expatwrap/saxwriter.cxx @@ -1158,15 +1158,11 @@ void SAXWriter::startElement(const OUString& aName, const Reference<XAttributeLi { if (!m_bDocStarted) { - SAXException except; - except.Message = "startElement called before startDocument"; - throw except; + throw SAXException("startElement called before startDocument", {}, {}); } if (m_bIsCDATA) { - SAXException except; - except.Message = "startElement call not allowed with CDATA sections"; - throw except; + throw SAXException("startElement call not allowed with CDATA sections", {}, {}); } sal_Int32 nLength(0); @@ -1210,15 +1206,12 @@ void SAXWriter::startElement(const OUString& aName, const Reference<XAttributeLi if (eRet == SAX_WARNING) { - SAXInvalidCharacterException except; - except.Message = "Invalid character during XML-Export in an attribute value"; - throw except; + throw SAXInvalidCharacterException( + "Invalid character during XML-Export in an attribute value", {}, {}); } else if (eRet == SAX_ERROR) { - SAXException except; - except.Message = "Invalid character during XML-Export"; - throw except; + throw SAXException("Invalid character during XML-Export", {}, {}); } } @@ -1262,9 +1255,7 @@ void SAXWriter::endElement(const OUString& aName) if (!bRet) { - SAXException except; - except.Message = "Invalid character during XML-Export"; - throw except; + throw SAXException("Invalid character during XML-Export", {}, {}); } } @@ -1272,9 +1263,7 @@ void SAXWriter::characters(const OUString& aChars) { if (!m_bDocStarted) { - SAXException except; - except.Message = "characters method called before startDocument"; - throw except; + throw SAXException("characters method called before startDocument", {}, {}); } bool bThrowException(false); @@ -1314,9 +1303,7 @@ void SAXWriter::characters(const OUString& aChars) } if (bThrowException) { - SAXInvalidCharacterException except; - except.Message = "Invalid character during XML-Export"; - throw except; + throw SAXInvalidCharacterException("Invalid character during XML-Export", {}, {}); } } @@ -1357,9 +1344,7 @@ void SAXWriter::processingInstruction(const OUString& aTarget, const OUString& a if (!m_pSaxWriterHelper->processingInstruction(aTarget, aData)) { - SAXException except; - except.Message = "Invalid character during XML-Export"; - throw except; + throw SAXException("Invalid character during XML-Export", {}, {}); } } @@ -1391,9 +1376,7 @@ void SAXWriter::endCDATA() { if (!m_bDocStarted || !m_bIsCDATA) { - SAXException except; - except.Message = "endCDATA was called without startCDATA"; - throw except; + throw SAXException("endCDATA was called without startCDATA", {}, {}); } sal_Int32 nPrefix = getIndentPrefixLength(3); @@ -1427,9 +1410,7 @@ void SAXWriter::comment(const OUString& sComment) if (!m_pSaxWriterHelper->comment(sComment)) { - SAXException except; - except.Message = "Invalid character during XML-Export"; - throw except; + throw SAXException("Invalid character during XML-Export", {}, {}); } } @@ -1467,9 +1448,7 @@ void SAXWriter::unknown(const OUString& sString) if (!m_pSaxWriterHelper->writeString(sString, false, false)) { - SAXException except; - except.Message = "Invalid character during XML-Export"; - throw except; + throw SAXException("Invalid character during XML-Export", {}, {}); } } diff --git a/sfx2/source/doc/DocumentMetadataAccess.cxx b/sfx2/source/doc/DocumentMetadataAccess.cxx index b58d8460ebd1..ea038791781a 100644 --- a/sfx2/source/doc/DocumentMetadataAccess.cxx +++ b/sfx2/source/doc/DocumentMetadataAccess.cxx @@ -488,18 +488,14 @@ mkException( OUString const & i_rMessage, ucb::IOErrorCode const i_ErrorCode, OUString const & i_rUri, OUString const & i_rResource) { - ucb::InteractiveAugmentedIOException iaioe; - iaioe.Message = i_rMessage; - iaioe.Classification = task::InteractionClassification_ERROR; - iaioe.Code = i_ErrorCode; - const beans::PropertyValue uriProp("Uri", -1, uno::Any(i_rUri), static_cast<beans::PropertyState>(0)); const beans::PropertyValue rnProp( "ResourceName", -1, uno::Any(i_rResource), static_cast<beans::PropertyState>(0)); - iaioe.Arguments = { uno::Any(uriProp), uno::Any(rnProp) }; - return iaioe; + return ucb::InteractiveAugmentedIOException(i_rMessage, {}, + task::InteractionClassification_ERROR, i_ErrorCode, + { uno::Any(uriProp), uno::Any(rnProp) }); } /** error handling policy. diff --git a/stoc/source/corereflection/criface.cxx b/stoc/source/corereflection/criface.cxx index 458c7c3693a7..23d3d9bae278 100644 --- a/stoc/source/corereflection/criface.cxx +++ b/stoc/source/corereflection/criface.cxx @@ -603,17 +603,13 @@ Any SAL_CALL IdlInterfaceMethodImpl::invoke( const Any & rObj, Sequence< Any > & } TYPELIB_DANGER_RELEASE( pReturnType ); - InvocationTargetException aExc; - aExc.Context = *o3tl::doAccess<Reference<XInterface>>(rObj); - aExc.Message = "exception occurred during invocation!"; - uno_any_destruct( - &aExc.TargetException, + uno_any_destruct(&aRet, reinterpret_cast< uno_ReleaseFunc >(cpp_release) ); - uno_type_copyAndConvertData( - &aExc.TargetException, pUnoExc, cppu::UnoType<Any>::get().getTypeLibType(), + uno_type_copyAndConvertData(&aRet, pUnoExc, cppu::UnoType<Any>::get().getTypeLibType(), getReflection()->getUno2Cpp().get() ); uno_any_destruct( pUnoExc, nullptr ); - throw aExc; + throw InvocationTargetException("exception occurred during invocation!", + *o3tl::doAccess<Reference<XInterface>>(rObj), aRet); } else { diff --git a/stoc/source/invocation/invocation.cxx b/stoc/source/invocation/invocation.cxx index 5c57f5107de9..7da24b3ae0d0 100644 --- a/stoc/source/invocation/invocation.cxx +++ b/stoc/source/invocation/invocation.cxx @@ -639,10 +639,7 @@ Any Invocation_Impl::invoke( const OUString& FunctionName, const Sequence<Any>& } else { - CannotConvertException aExc; - aExc.Context = *this; - aExc.Message = "invocation type mismatch!"; - throw aExc; + throw CannotConvertException("invocation type mismatch!", *this, {}, 0, 0); } } @@ -675,10 +672,7 @@ Any Invocation_Impl::invoke( const OUString& FunctionName, const Sequence<Any>& return aRet; } - RuntimeException aExc; - aExc.Context = *this; - aExc.Message = "invocation lacking of introspection access!"; - throw aExc; + throw RuntimeException("invocation lacking of introspection access!", *this); } namespace { diff --git a/stoc/source/servicemanager/servicemanager.cxx b/stoc/source/servicemanager/servicemanager.cxx index cc2a51026ab5..c61e23cf8546 100644 --- a/stoc/source/servicemanager/servicemanager.cxx +++ b/stoc/source/servicemanager/servicemanager.cxx @@ -687,8 +687,7 @@ Any OServiceManager::getPropertyValue(const OUString& PropertyName) } else { - UnknownPropertyException except; - except.Message = "ServiceManager : unknown property " + PropertyName; + UnknownPropertyException except("ServiceManager : unknown property " + PropertyName, {}); throw except; } } diff --git a/svx/source/fmcomp/gridcell.cxx b/svx/source/fmcomp/gridcell.cxx index cb8ccf91955f..7e9dfb35bff7 100644 --- a/svx/source/fmcomp/gridcell.cxx +++ b/svx/source/fmcomp/gridcell.cxx @@ -2971,8 +2971,7 @@ bool DbFilterField::commitControl() else { - SQLException aError; - aError.Message = aErrorMsg; + SQLException aError(aErrorMsg, {}, {}, 0, {}); displayException(aError, VCLUnoHelper::GetInterface(m_pWindow->GetParent())); // TODO: transport the title diff --git a/svx/source/form/filtnav.cxx b/svx/source/form/filtnav.cxx index 7ac5dc4d7982..ae16670d093c 100644 --- a/svx/source/form/filtnav.cxx +++ b/svx/source/form/filtnav.cxx @@ -1151,9 +1151,7 @@ IMPL_LINK(FmFilterNavigator, EditedEntryHdl, const IterString&, rIterString, boo else { // display the error and return sal_False - SQLContext aError; - aError.Message = SvxResId(RID_STR_SYNTAXERROR); - aError.Details = aErrorMsg; + SQLContext aError(SvxResId(RID_STR_SYNTAXERROR), {}, {}, 0, {}, aErrorMsg); displayException(aError, VCLUnoHelper::GetInterface(m_xTopLevel)); return false; diff --git a/svx/source/form/formcontroller.cxx b/svx/source/form/formcontroller.cxx index 3a241c4d315c..68e9b1f5274c 100644 --- a/svx/source/form/formcontroller.cxx +++ b/svx/source/form/formcontroller.cxx @@ -3524,9 +3524,7 @@ namespace void displayErrorSetFocus(const OUString& _rMessage, const Reference<XControl>& _rxFocusControl, const css::uno::Reference<css::awt::XWindow>& rDialogParent) { - SQLContext aError; - aError.Message = SvxResId(RID_STR_WRITEERROR); - aError.Details = _rMessage; + SQLContext aError(SvxResId(RID_STR_WRITEERROR), {}, {}, 0, {}, _rMessage); displayException(aError, rDialogParent); if ( _rxFocusControl.is() ) @@ -3926,11 +3924,8 @@ sal_Bool SAL_CALL FormController::confirmDelete(const RowChangeEvent& aEvent) rtl::Reference<OInteractionDisapprove> pDisapprove = new OInteractionDisapprove; // the request - SQLWarning aWarning; - aWarning.Message = sTitle; - SQLWarning aDetails; - aDetails.Message = SvxResId(RID_STR_DELETECONFIRM); - aWarning.NextException <<= aDetails; + SQLWarning aDetails(SvxResId(RID_STR_DELETECONFIRM), {}, {}, 0, {}); + SQLWarning aWarning(sTitle, {}, {}, 0, css::uno::Any(aDetails)); rtl::Reference<OInteractionRequest> pRequest = new OInteractionRequest( Any( aWarning ) ); diff --git a/svx/source/form/formcontrolling.cxx b/svx/source/form/formcontrolling.cxx index 81edd4862129..89d2182fefee 100644 --- a/svx/source/form/formcontrolling.cxx +++ b/svx/source/form/formcontrolling.cxx @@ -338,14 +338,14 @@ namespace svx } catch ( const SQLException& ) { - m_xFormOperations->getController()->removeSQLErrorListener( const_cast< FormControllerHelper* >(this) ); aError = ::cppu::getCaughtException(); + m_xFormOperations->getController()->removeSQLErrorListener( const_cast< FormControllerHelper* >(this) ); } catch( const Exception& ) { + aError = ::cppu::getCaughtException(); m_xFormOperations->getController()->removeSQLErrorListener( const_cast< FormControllerHelper* >(this) ); - SQLException aFallbackError; - aFallbackError.Message = ::comphelper::anyToString( ::cppu::getCaughtException() ); + SQLException aFallbackError(::comphelper::anyToString(aError), {}, {}, 0, {}); aError <<= aFallbackError; } diff --git a/testtools/source/bridgetest/bridgetest.cxx b/testtools/source/bridgetest/bridgetest.cxx index 9e3eb90c1de9..6e09923dcaac 100644 --- a/testtools/source/bridgetest/bridgetest.cxx +++ b/testtools/source/bridgetest/bridgetest.cxx @@ -1005,7 +1005,8 @@ static bool raiseOnewayException( const Reference < XBridgeTest > & xLBT ) bReturn = ( #if OSL_DEBUG_LEVEL == 0 // java stack traces trash Message - e.Message == STRING_TEST_CONSTANT && + // The message might also contain source location + e.Message.indexOf(STRING_TEST_CONSTANT) >= 0 && #endif xLBT->getInterface() == e.Context && x == e.Context ); diff --git a/testtools/source/bridgetest/cppobj.cxx b/testtools/source/bridgetest/cppobj.cxx index 32742110f341..1e0029939c06 100644 --- a/testtools/source/bridgetest/cppobj.cxx +++ b/testtools/source/bridgetest/cppobj.cxx @@ -682,19 +682,16 @@ void Test_Impl::setValues( sal_Bool bBool, ::test::testtools::bridgetest::TestDataElements Test_Impl::raiseException( sal_Int16 nArgumentPos, const OUString & rMsg, const Reference< XInterface > & xContext ) { - IllegalArgumentException aExc; - aExc.ArgumentPosition = nArgumentPos; - aExc.Message = _aData.String = rMsg; - aExc.Context = _aData.Interface = xContext; - throw aExc; + _aData.String = rMsg; + _aData.Interface = xContext; + throw IllegalArgumentException(rMsg, xContext, nArgumentPos); } void Test_Impl::raiseRuntimeExceptionOneway( const OUString & rMsg, const Reference< XInterface > & xContext ) { - RuntimeException aExc; - aExc.Message = _aData.String = rMsg; - aExc.Context = _aData.Interface = xContext; - throw aExc; + _aData.String = rMsg; + _aData.Interface = xContext; + throw RuntimeException(rMsg, xContext); } static void dothrow2(const RuntimeException& e) @@ -745,9 +742,7 @@ sal_Int32 Test_Impl::getRuntimeException() void Test_Impl::setRuntimeException( sal_Int32 ) { - RuntimeException aExc; - aExc.Message = _aData.String; - aExc.Context = _aData.Interface; + RuntimeException aExc(_aData.String, _aData.Interface); throwException( Any( aExc ) ); } diff --git a/toolkit/source/awt/vclxwindow1.cxx b/toolkit/source/awt/vclxwindow1.cxx index 7b7b7192f9db..edc78f7d9258 100644 --- a/toolkit/source/awt/vclxwindow1.cxx +++ b/toolkit/source/awt/vclxwindow1.cxx @@ -39,9 +39,7 @@ void VCLXWindow::SetSystemParent_Impl(const css::uno::Any& rHandle) VclPtr<vcl::Window> pWindow = GetWindow(); if (pWindow->GetType() != WindowType::WORKWINDOW) { - css::uno::RuntimeException aException; - aException.Message = "not a work window"; - throw aException; + throw css::uno::RuntimeException("not a work window"); } // use sal_Int64 here to accommodate all int types @@ -67,9 +65,7 @@ void VCLXWindow::SetSystemParent_Impl(const css::uno::Any& rHandle) } if (bThrow) { - css::uno::RuntimeException aException; - aException.Message = "incorrect window handle type"; - throw aException; + throw css::uno::RuntimeException("incorrect window handle type"); } // create system parent data SystemParentData aSysParentData; diff --git a/toolkit/source/controls/unocontrol.cxx b/toolkit/source/controls/unocontrol.cxx index c47048b3a4b6..0880455581ea 100644 --- a/toolkit/source/controls/unocontrol.cxx +++ b/toolkit/source/controls/unocontrol.cxx @@ -1074,10 +1074,7 @@ void UnoControl::createPeer( const Reference< XToolkit >& rxToolkit, const Refer ::osl::ClearableMutexGuard aGuard( GetMutex() ); if ( !mxModel.is() ) { - RuntimeException aException; - aException.Message = "createPeer: no model!"; - aException.Context = static_cast<XAggregation*>(static_cast<cppu::OWeakAggObject*>(this)); - throw aException; + throw RuntimeException("createPeer: no model!", getXWeak()); } if( getPeer().is() ) diff --git a/ucb/source/ucp/file/filglob.cxx b/ucb/source/ucp/file/filglob.cxx index a86716509a24..a5097f51117e 100644 --- a/ucb/source/ucp/file/filglob.cxx +++ b/ucb/source/ucp/file/filglob.cxx @@ -546,17 +546,13 @@ namespace fileaccess { else if( errorCode == TASKHANDLING_NOREPLACE_FOR_WRITE ) // Overwrite = false and file exists { - NameClashException excep; - excep.Name = getTitle(aUncPath); - excep.Classification = InteractionClassification_ERROR; - excep.Context = Reference<XInterface>( xComProc, UNO_QUERY ); - excep.Message = "file exists and overwrite forbidden"; + NameClashException excep("file exists and overwrite forbidden", + Reference<XInterface>(xComProc, UNO_QUERY), + InteractionClassification_ERROR, OUString(getTitle(aUncPath))); cancelCommandExecution( Any(excep), xEnv ); } else if( errorCode == TASKHANDLING_INVALID_NAME_MKDIR ) { - InteractiveAugmentedIOException excep; - excep.Code = IOErrorCode_INVALID_CHARACTER; PropertyValue prop; prop.Name = "ResourceName"; prop.Handle = -1; @@ -566,10 +562,9 @@ namespace fileaccess { rtl_UriDecodeWithCharset, RTL_TEXTENCODING_UTF8)); prop.Value <<= aClashingName; - excep.Arguments = { Any(prop) }; - excep.Classification = InteractionClassification_ERROR; - excep.Context = Reference<XInterface>( xComProc, UNO_QUERY ); - excep.Message = "the name contained invalid characters"; + InteractiveAugmentedIOException excep( + "the name contained invalid characters", Reference<XInterface>(xComProc, UNO_QUERY), + InteractionClassification_ERROR, IOErrorCode_INVALID_CHARACTER, { Any(prop) }); if(isHandled) throw excep; cancelCommandExecution( Any(excep), xEnv ); @@ -583,11 +578,8 @@ namespace fileaccess { } else if( errorCode == TASKHANDLING_FOLDER_EXISTS_MKDIR ) { - NameClashException excep; - excep.Name = getTitle(aUncPath); - excep.Classification = InteractionClassification_ERROR; - excep.Context = xComProc; - excep.Message = "folder exists and overwrite forbidden"; + NameClashException excep("folder exists and overwrite forbidden", xComProc, + InteractionClassification_ERROR, OUString(getTitle(aUncPath))); if(isHandled) throw excep; cancelCommandExecution( Any(excep), xEnv ); @@ -835,21 +827,18 @@ namespace fileaccess { else if( errorCode == TASKHANDLING_NAMECLASH_FOR_COPY || errorCode == TASKHANDLING_NAMECLASH_FOR_MOVE ) { - NameClashException excep; - excep.Name = getTitle(aUncPath); - excep.Classification = InteractionClassification_ERROR; - excep.Context = Reference<XInterface>( xComProc, UNO_QUERY ); - excep.Message = "name clash during copy or move"; + NameClashException excep("name clash during copy or move", + Reference<XInterface>(xComProc, UNO_QUERY), + InteractionClassification_ERROR, OUString(getTitle(aUncPath))); cancelCommandExecution(Any(excep), xEnv); } else if( errorCode == TASKHANDLING_NAMECLASHSUPPORT_FOR_MOVE || errorCode == TASKHANDLING_NAMECLASHSUPPORT_FOR_COPY ) { - UnsupportedNameClashException excep; - excep.NameClash = minorCode; - excep.Context = Reference<XInterface>( xComProc, UNO_QUERY ); - excep.Message = "name clash value not supported during copy or move"; + UnsupportedNameClashException excep( + "name clash value not supported during copy or move", + Reference<XInterface>(xComProc, UNO_QUERY), minorCode); cancelCommandExecution(Any(excep), xEnv); } diff --git a/ucb/source/ucp/file/filinsreq.cxx b/ucb/source/ucp/file/filinsreq.cxx index 3e20f8bee68e..0b8ebfb5395e 100644 --- a/ucb/source/ucp/file/filinsreq.cxx +++ b/ucb/source/ucp/file/filinsreq.cxx @@ -55,25 +55,19 @@ XInteractionRequestImpl::XInteractionRequestImpl( Any aAny; if(nErrorCode == TASKHANDLING_FOLDER_EXISTS_MKDIR) { - NameClashException excep; - excep.Name = aClashingName; - excep.Classification = InteractionClassification_ERROR; - excep.Context = m_xOrigin; - excep.Message = "folder exists and overwrite forbidden"; + NameClashException excep("folder exists and overwrite forbidden", m_xOrigin, + InteractionClassification_ERROR, aClashingName); aAny <<= excep; } else if(nErrorCode == TASKHANDLING_INVALID_NAME_MKDIR) { - InteractiveAugmentedIOException excep; - excep.Code = IOErrorCode_INVALID_CHARACTER; PropertyValue prop; prop.Name = "ResourceName"; prop.Handle = -1; prop.Value <<= aClashingName; - excep.Arguments = { Any(prop) }; - excep.Classification = InteractionClassification_ERROR; - excep.Context = m_xOrigin; - excep.Message = "the name contained invalid characters"; + InteractiveAugmentedIOException excep("the name contained invalid characters", m_xOrigin, + InteractionClassification_ERROR, + IOErrorCode_INVALID_CHARACTER, { Any(prop) }); aAny <<= excep; } diff --git a/ucb/source/ucp/file/filstr.cxx b/ucb/source/ucp/file/filstr.cxx index 2e49a7c8f8c2..70c235da7d9b 100644 --- a/ucb/source/ucp/file/filstr.cxx +++ b/ucb/source/ucp/file/filstr.cxx @@ -212,9 +212,7 @@ XStream_impl::closeStream() osl::FileBase::RC err = m_aFile.close(); if( err != osl::FileBase::E_None ) { - io::IOException ex; - ex.Message = "could not close file"; - throw ex; + throw io::IOException("could not close file"); } m_nIsOpen = false; diff --git a/ucbhelper/source/provider/cancelcommandexecution.cxx b/ucbhelper/source/provider/cancelcommandexecution.cxx index 42850c5ee306..57166e49b065 100644 --- a/ucbhelper/source/provider/cancelcommandexecution.cxx +++ b/ucbhelper/source/provider/cancelcommandexecution.cxx @@ -80,12 +80,8 @@ void cancelCommandExecution( const ucb::IOErrorCode eError, { // Fast path - ucb::InteractiveAugmentedIOException aRequest; - aRequest.Message = rMessage; - aRequest.Context = xContext; - aRequest.Classification = task::InteractionClassification_ERROR; - aRequest.Code = eError; - aRequest.Arguments = rArgs; + ucb::InteractiveAugmentedIOException aRequest( + rMessage, xContext, task::InteractionClassification_ERROR, eError, rArgs); cppu::throwException( uno::Any( aRequest ) ); } else diff --git a/ucbhelper/source/provider/simpleioerrorrequest.cxx b/ucbhelper/source/provider/simpleioerrorrequest.cxx index df28f63525bc..0c0857f915c1 100644 --- a/ucbhelper/source/provider/simpleioerrorrequest.cxx +++ b/ucbhelper/source/provider/simpleioerrorrequest.cxx @@ -32,12 +32,8 @@ SimpleIOErrorRequest::SimpleIOErrorRequest( const uno::Reference< ucb::XCommandProcessor > & xContext ) { // Fill request... - ucb::InteractiveAugmentedIOException aRequest; - aRequest.Message = rMessage; - aRequest.Context = xContext; - aRequest.Classification = task::InteractionClassification_ERROR; - aRequest.Code = eError; - aRequest.Arguments = rArgs; + ucb::InteractiveAugmentedIOException aRequest( + rMessage, xContext, task::InteractionClassification_ERROR, eError, rArgs); setRequest( uno::Any( aRequest ) ); diff --git a/unotools/source/ucbhelper/ucblockbytes.cxx b/unotools/source/ucbhelper/ucblockbytes.cxx index 0a46323b57eb..182b1f674e1c 100644 --- a/unotools/source/ucbhelper/ucblockbytes.cxx +++ b/unotools/source/ucbhelper/ucblockbytes.cxx @@ -728,14 +728,13 @@ static bool UCBOpenContentSync( { Reference<XInteractionRetry> xRet; if(xInteract.is()) { - InteractiveNetworkConnectException aExcep; INetURLObject aURL( xContId.is() ? xContId->getContentIdentifier() : OUString() ); - aExcep.Server = aURL.GetHost(); - aExcep.Classification = InteractionClassification_ERROR; - aExcep.Message = "server not responding after five seconds"; + InteractiveNetworkConnectException aExcep( + "server not responding after five seconds", {}, + InteractionClassification_ERROR, aURL.GetHost()); Any request; request <<= aExcep; rtl::Reference<ucbhelper::InteractionRequest> xIR = diff --git a/unoxml/source/dom/documentbuilder.cxx b/unoxml/source/dom/documentbuilder.cxx index a7cc288eea40..c3cd7663d2fc 100644 --- a/unoxml/source/dom/documentbuilder.cxx +++ b/unoxml/source/dom/documentbuilder.cxx @@ -256,10 +256,8 @@ namespace DOM if (pDocBuilder->getErrorHandler().is()) // if custom error handler is set (using setErrorHandler ()) { // Prepare SAXParseException to be passed to custom XErrorHandler::warning function - css::xml::sax::SAXParseException saxex; - saxex.Message = make_error_message(pctx); - saxex.LineNumber = static_cast<sal_Int32>(pctx->lastError.line); - saxex.ColumnNumber = static_cast<sal_Int32>(pctx->lastError.int2); + css::xml::sax::SAXParseException saxex(make_error_message(pctx), {}, {}, {}, {}, + pctx->lastError.line, pctx->lastError.int2); // Call custom warning function pDocBuilder->getErrorHandler()->warning(::css::uno::Any(saxex)); @@ -288,10 +286,8 @@ namespace DOM if (pDocBuilder->getErrorHandler().is()) // if custom error handler is set (using setErrorHandler ()) { // Prepare SAXParseException to be passed to custom XErrorHandler::error function - css::xml::sax::SAXParseException saxex; - saxex.Message = make_error_message(pctx); - saxex.LineNumber = static_cast<sal_Int32>(pctx->lastError.line); - saxex.ColumnNumber = static_cast<sal_Int32>(pctx->lastError.int2); + css::xml::sax::SAXParseException saxex(make_error_message(pctx), {}, {}, {}, {}, + pctx->lastError.line, pctx->lastError.int2); // Call custom warning function pDocBuilder->getErrorHandler()->error(::css::uno::Any(saxex)); @@ -307,10 +303,8 @@ namespace DOM static void throwEx(xmlParserCtxtPtr ctxt) { - css::xml::sax::SAXParseException saxex; - saxex.Message = make_error_message(ctxt); - saxex.LineNumber = static_cast<sal_Int32>(ctxt->lastError.line); - saxex.ColumnNumber = static_cast<sal_Int32>(ctxt->lastError.int2); + css::xml::sax::SAXParseException saxex(make_error_message(ctxt), {}, {}, {}, {}, + ctxt->lastError.line, ctxt->lastError.int2); throw saxex; } |