diff --git a/agenda/fx.py b/agenda/fx.py index 90cbc5f..efd4d7d 100644 --- a/agenda/fx.py +++ b/agenda/fx.py @@ -90,10 +90,14 @@ def get_rates(config: flask.config.Config) -> dict[str, Decimal]: except httpx.ConnectError: return read_cached_rates(full_path, currencies) + try: + data = json.loads(response.text, parse_float=Decimal) + except json.decoder.JSONDecodeError: + return read_cached_rates(full_path, currencies) + with open(os.path.join(fx_dir, filename), "w") as file: file.write(response.text) - data = json.loads(response.text, parse_float=Decimal) return { cur: Decimal(data["quotes"][f"GBP{cur}"]) for cur in currencies