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 /reportdesign/source/ui | |
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>
Diffstat (limited to 'reportdesign/source/ui')
-rw-r--r-- | reportdesign/source/ui/report/ReportController.cxx | 34 |
1 files changed, 14 insertions, 20 deletions
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; } |