Merge pull request #102 into master
d7b25e0php: fetch: prices: base: catch unrecoverable CoinGecko error (Aaron Fiore)f222a5ephp: fetch: prices: crypto: throw errors with nested status (Aaron Fiore)
This commit was merged in pull request #102.
This commit is contained in:
@@ -354,10 +354,18 @@ namespace docker_finance\prices\internal
|
||||
$code = $e->getCode();
|
||||
$message = $e->getMessage();
|
||||
|
||||
utils\CLI::print_warning(
|
||||
"server sent error '{$message}' with code '{$code}' for '{$asset['id']}'"
|
||||
. " - retrying in '{$timer}' seconds"
|
||||
);
|
||||
$print = "server sent error '{$message}' with code '{$code}' for '{$asset['id']}'"
|
||||
. " - retrying in '{$timer}' seconds";
|
||||
|
||||
switch ($code) {
|
||||
// CoinGecko's unrecoverable error (paid plan needed)
|
||||
case 10012:
|
||||
utils\CLI::throw_fatal($print);
|
||||
break;
|
||||
default:
|
||||
utils\CLI::print_warning($print);
|
||||
break;
|
||||
}
|
||||
|
||||
$i = 1;
|
||||
$j = 1;
|
||||
|
||||
@@ -58,6 +58,10 @@ namespace docker_finance\prices\internal\prices\crypto
|
||||
$url = "https://{$domain}/api/v3/coins/{$asset['id']}/market_chart?vs_currency={$vs_currency}&days={$timestamp}";
|
||||
|
||||
$response = $this->request_impl($url, $header);
|
||||
if (array_key_exists('error', $response)) {
|
||||
$status = $response['error']['status'];
|
||||
throw new \Exception($status['error_message'], $status['error_code']);
|
||||
}
|
||||
if (array_key_exists('status', $response)) {
|
||||
$status = $response['status'];
|
||||
throw new \Exception($status['error_message'], $status['error_code']);
|
||||
|
||||
Reference in New Issue
Block a user