Skip to content

Commit

Permalink
catch json error (#660)
Browse files Browse the repository at this point in the history
  • Loading branch information
callebtc authored Nov 2, 2024
1 parent 0b2a020 commit 872fdbf
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion cashu/wallet/wallet_deprecated.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import json
from posixpath import join
from typing import List, Optional, Tuple, Union

Expand Down Expand Up @@ -106,7 +107,12 @@ def raise_on_error(
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']}"
Expand Down

0 comments on commit 872fdbf

Please sign in to comment.