Bug 796993 - Get Quotes: Err msg if Alpha Vantage API key needed

AlphaVantage API Key is needed for all currency quotes
and stock quotes with source 'alphavantage' or 'vanguard' or
multi sources that include 'alphavantage'.
Give an error message instead of failing with no reason.
This commit is contained in:
goodvibes2 2020-06-12 15:20:57 +10:00
parent 60da4bd7bf
commit f1ff45ecae

View File

@ -128,6 +128,9 @@
(catch #t (catch #t
(lambda () (lambda ()
(gnc:debug "handling-request: " request) (gnc:debug "handling-request: " request)
(and (member (car request) '("currency" "alphavantage" "vanguard"))
(not (getenv "ALPHAVANTAGE_API_KEY"))
(throw 'need-alphavantage-key))
;; we need to display the first element (the method, ;; we need to display the first element (the method,
;; so it won't be quoted) and then write the rest ;; so it won't be quoted) and then write the rest
(with-output-to-port (fdes->outport (gnc-process-get-fd quoter 0)) (with-output-to-port (fdes->outport (gnc-process-get-fd quoter 0))
@ -447,6 +450,11 @@
(show-error (N_ "You are missing some needed Perl libraries. (show-error (N_ "You are missing some needed Perl libraries.
Run 'gnc-fq-update' as root to install them."))) Run 'gnc-fq-update' as root to install them.")))
((memq 'need-alphavantage-key fq-results)
(set! keep-going? #f)
(show-error (N_ "ERROR: ALPHAVANTAGE_API_KEY must be set for currency \
+ quotes; see https://wiki.gnucash.org/wiki/Online_Quotes#Source_Alphavantage.2C_US")))
((memq 'system-error fq-results) ((memq 'system-error fq-results)
(set! keep-going? #f) (set! keep-going? #f)
(show-error (N_ "There was a system error while retrieving the price quotes."))) (show-error (N_ "There was a system error while retrieving the price quotes.")))