gnucash stable: Improve reporting when parse_quote throws an exception.
John Ralls
jralls at code.gnucash.org
Tue Aug 8 18:45:15 EDT 2023
Updated via https://github.com/Gnucash/gnucash/commit/a5404f66 (commit)
from https://github.com/Gnucash/gnucash/commit/0909fd9b (commit)
commit a5404f6607c16a79d438fccc01e0a3e58fac0b85
Author: John Ralls <jralls at ceridwen.us>
Date: Tue Aug 8 15:37:49 2023 -0700
Improve reporting when parse_quote throws an exception.
Add more detail to the error message and pass the right value to the
gnc_error_dialog so that the error is actually displayed to the user.
diff --git a/gnucash/gnome/dialog-price-edit-db.cpp b/gnucash/gnome/dialog-price-edit-db.cpp
index 2d60fec620..7d906d95e7 100644
--- a/gnucash/gnome/dialog-price-edit-db.cpp
+++ b/gnucash/gnome/dialog-price-edit-db.cpp
@@ -569,7 +569,7 @@ gnc_prices_dialog_get_quotes_clicked (GtkWidget *widget, gpointer data)
{
gnc_unset_busy_cursor(nullptr);
PERR("Price retrieval failed: %s", err.what());
- gnc_error_dialog(GTK_WINDOW(pdb_dialog), _("Price retrieval failed: %s"), err.what());
+ gnc_error_dialog(GTK_WINDOW(pdb_dialog->window), _("Price retrieval failed: %s"), err.what());
}
/* Without this, the summary bar on the accounts tab
diff --git a/libgnucash/app-utils/gnc-quotes.cpp b/libgnucash/app-utils/gnc-quotes.cpp
index bd19d270d2..31c8cf6ca8 100644
--- a/libgnucash/app-utils/gnc-quotes.cpp
+++ b/libgnucash/app-utils/gnc-quotes.cpp
@@ -728,7 +728,7 @@ GncQuotesImpl::parse_quotes (const std::string& quote_str)
{
bpt::ptree pt;
std::istringstream ss {quote_str};
- const char* what = nullptr;
+ std::string what;
try
{
@@ -747,15 +747,26 @@ GncQuotesImpl::parse_quotes (const std::string& quote_str)
}
catch (...) {
std::string error_msg{_("Failed to parse result returned by Finance::Quote.")};
+ error_msg += "\n";
+ //Translators: This labels the return value of a query to Finance::Quote written in an error.
+ error_msg += _("Result:");
+ error_msg += "\n";
+ error_msg += quote_str;
throw(GncQuoteException(error_msg));
}
- if (what)
+ if (!what.empty())
{
std::string error_msg{_("Failed to parse result returned by Finance::Quote.")};
error_msg += "\n";
+ //Translators: This is the error message reported by the Online Quotes processing code.
error_msg += _("Error message:");
error_msg += "\n";
error_msg += what;
+ error_msg += "\n";
+ //Translators: This labels the return value of a query to Finance::Quote written in an error.
+ error_msg += _("Result:");
+ error_msg += "\n";
+ error_msg += quote_str;
throw(GncQuoteException(error_msg));
}
return pt;
Summary of changes:
gnucash/gnome/dialog-price-edit-db.cpp | 2 +-
libgnucash/app-utils/gnc-quotes.cpp | 15 +++++++++++++--
2 files changed, 14 insertions(+), 3 deletions(-)
More information about the gnucash-changes
mailing list