php: fetch: prices: base: catch unrecoverable CoinGecko error

Thrown when 'all' years are requested without paid-plan API key.
This commit is contained in:
2024-07-30 22:42:51 -07:00
parent f222a5e654
commit d7b25e0dae

View File

@@ -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;