[price-quotes] Report quote fetch failures to the user.

This commit is contained in:
John Ralls 2022-09-18 15:06:59 -07:00
parent 4c47e91180
commit 6ffb0bb633
4 changed files with 19 additions and 1 deletions

View File

@ -564,6 +564,9 @@ gnc_prices_dialog_get_quotes_clicked (GtkWidget *widget, gpointer data)
gnc_set_busy_cursor (NULL, TRUE);
quotes.fetch (pdb_dialog->book);
gnc_unset_busy_cursor (NULL);
if (quotes.had_failures())
gnc_warning_dialog(GTK_WINDOW(pdb_dialog->window), "%s",
quotes.report_failures().c_str());
}
catch (const GncQuoteException& err)
{

View File

@ -346,10 +346,12 @@ Gnucash::add_quotes (const bo_str& uri)
gnc_quote_source_set_fq_installed (quotes.version().c_str(), quote_sources);
g_list_free_full (quote_sources, g_free);
quotes.fetch(qof_session_get_book(session));
if (quotes.had_failures())
std::cerr << quotes.report_failures() << std::endl;
}
catch (const GncQuoteException& err)
{
std::cerr << err.what() << std::endl;
std::cerr << bl::translate("Price retrieval failed: ") << err.what() << std::endl;
}
qof_session_save(session, NULL);
if (qof_session_get_error(session) != ERR_BACKEND_NO_ERR)

View File

@ -96,6 +96,7 @@ public:
const std::string& version() noexcept { return m_version.empty() ? not_found : m_version; }
const QuoteSources& sources() noexcept { return m_sources; }
GList* sources_as_glist ();
bool had_failures() noexcept { return !m_failures.empty(); }
const QFVec& failures() noexcept;
std::string report_failures() noexcept;
@ -821,6 +822,12 @@ GList* GncQuotes::sources_as_glist ()
GncQuotes::~GncQuotes() = default;
bool
GncQuotes::had_failures() noexcept
{
return m_impl->had_failures();
}
const QFVec&
GncQuotes::failures() noexcept
{

View File

@ -111,6 +111,12 @@ public:
*/
GList* sources_as_glist () ;
/** Report if there were quotes requested but not retrieved.
*
* @returns True if there were quote failures.
*/
bool had_failures() noexcept;
/** Report the commodities for which quotes were requested but not successfully retrieved.
*
* This does not include requested commodities that didn't have a quote source.