[GNC-dev] Bug 798466 - Propagating Errors Messages From Finance::Quote to GnuCash

Bruce Schuck <[email protected]>
Newsgroups gmane.comp.gnome.apps.gnucash.devel
Message-ID <[email protected]>
Hello,

I've been reading bugs https://bugs.gnucash.org/show_bug.cgi?id=798466 
and https://bugs.gnucash.org/show_bug.cgi?id=798449. Looking at the 
GnuCash source, specifically gnucash/price-quotes.scm and 
libgnucash/quotes/gnc-fq-helper.in, I notice that the "errormsg" value 
passed as part of the data returned from most of the F::Q modules is 
ignored and not utilized.

Perhaps displaying the string(s) returned when F::Q fails would be 
helpful? Fetching multiple stock quotes, especially when they are 
fetched from different sources, could result in multiple error messages 
during a price update.

To see different messages change 'demo' to '' or a random string in the 
following code.

=====

use Finance::Quote;
my $q = Finance::Quote->new('alphavantage' => {API_KEY => 'demo'});
%quotes = $q->fetch("alphavantage", "F");
print "The price of Ford is " . $quotes{"F", "last"} . "\n";
if ( defined($quotes{"F","errormsg"}) ) {
   print "Errormsg: " . $quotes{"F","errormsg"} . "\n";
}

Returns:

The price of Ford is
Errormsg: The **demo** API key is for demo purposes only. Please claim 
your free API key at (https://www.alphavantage.co/support/#api-key) to 
explore our full API offerings. It takes fewer than 20 seconds.

=====

use Finance::Quote;
my $q = Finance::Quote->new('alphavantage' => {API_KEY => ''});
%quotes = $q->fetch("alphavantage", "F");
print "The price of Ford is " . $quotes{"F", "last"} . "\n";
if ( defined($quotes{"F","errormsg"}) ) {
   print "Errormsg: " . $quotes{"F","errormsg"} . "\n";
}

Returns:

The price of Ford is
Errormsg: the parameter apikey is invalid or missing. Please claim your 
free API key on (https://www.alphavantage.co/support/#api-key). It 
should take less than 20 seconds.

=====

Oddly enough while experimenting with this I found that any random 
string can be used as a "free" AlphaVantage API key. I reported this to 
them last year and so far the behavior has not changed.

BTW - I hope to have F::Q 1.52 released next month.

- Bruce S.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.