Merge pull request #321 into master

983313c0 container: finance: fetch: prices: improve handling of non-200 responses (Aaron Fiore)
This commit is contained in:
2026-03-13 16:30:30 -07:00
2 changed files with 15 additions and 6 deletions

View File

@@ -361,16 +361,17 @@ namespace dfi\prices\internal
$code = $e->getCode();
$message = $e->getMessage();
$print = "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']}'";
switch ($code) {
// CoinGecko's unrecoverable error (paid plan needed)
case 10012:
case 400:
utils\CLI::throw_fatal($print);
break;
case 10012: // CoinGecko's unrecoverable error (paid plan needed)
utils\CLI::throw_fatal($print);
break;
default:
utils\CLI::print_warning($print);
utils\CLI::print_warning($print . " - retrying in '{$timer}' seconds");
break;
}

View File

@@ -2,7 +2,7 @@
// docker-finance | modern accounting for the power-user
//
// Copyright (C) 2021-2025 Aaron Fiore (Founder, Evergreen Crypto LLC)
// Copyright (C) 2021-2026 Aaron Fiore (Founder, Evergreen Crypto LLC)
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
@@ -182,6 +182,14 @@ namespace dfi\prices\internal\prices\crypto
}
$response = $this->request_impl($url, $header);
if (array_key_exists('statusCode', $response)) {
switch ($response['statusCode']) {
case 200:
break;
default:
throw new \Exception($response['message'], $response['statusCode']);
}
}
if (array_key_exists('error', $response)) {
throw new \Exception($response['error']);
}