catch json error (#660)

This commit is contained in:
callebtc
2024-11-02 15:06:01 +01:00
committed by GitHub
parent 0b2a020ab6
commit 872fdbf519

View File

@@ -1,3 +1,4 @@
import json
from posixpath import join
from typing import List, Optional, Tuple, Union
@@ -106,7 +107,12 @@ class LedgerAPIDeprecated(SupportsHttpxClient, SupportsMintURL):
Raises:
Exception: if the response contains an error
"""
resp_dict = resp.json()
try:
resp_dict = resp.json()
except json.JSONDecodeError:
# if we can't decode the response, raise for status
resp.raise_for_status()
return
if "detail" in resp_dict:
logger.trace(f"Error from mint: {resp_dict}")
error_message = f"Mint Error: {resp_dict['detail']}"