This commit is contained in:
James Cole 2023-03-09 08:14:30 +01:00
parent 2e89586559
commit edd7aed691
No known key found for this signature in database
GPG Key ID: B49A324B7EAD6D80

View File

@ -30,6 +30,7 @@ use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
use FireflyIII\Repositories\User\UserRepositoryInterface; use FireflyIII\Repositories\User\UserRepositoryInterface;
use GuzzleHttp\Client; use GuzzleHttp\Client;
use GuzzleHttp\Exception\GuzzleException; use GuzzleHttp\Exception\GuzzleException;
use GuzzleHttp\Exception\RequestException;
use Illuminate\Bus\Queueable; use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable; use Illuminate\Foundation\Bus\Dispatchable;
@ -102,7 +103,12 @@ class DownloadExchangeRates implements ShouldQueue
$base = sprintf('%s/%s/%s', (string)config('cer.url'), $this->date->year, $this->date->isoWeek); $base = sprintf('%s/%s/%s', (string)config('cer.url'), $this->date->year, $this->date->isoWeek);
$client = new Client(); $client = new Client();
$url = sprintf('%s/%s.json', $base, $currency->code); $url = sprintf('%s/%s.json', $base, $currency->code);
try {
$res = $client->get($url); $res = $client->get($url);
} catch(RequestException $e) {
app('log')->warning(sprintf('Trying to grab "%s" resulted in error "%d".', $url, $e->getMessage()));
return;
}
$statusCode = $res->getStatusCode(); $statusCode = $res->getStatusCode();
if (200 !== $statusCode) { if (200 !== $statusCode) {
app('log')->warning(sprintf('Trying to grab "%s" resulted in status code %d.', $url, $statusCode)); app('log')->warning(sprintf('Trying to grab "%s" resulted in status code %d.', $url, $statusCode));