summaryrefslogtreecommitdiff
path: root/macaroonbakery/httpbakery/_client.py
diff options
context:
space:
mode:
Diffstat (limited to 'macaroonbakery/httpbakery/_client.py')
-rw-r--r--macaroonbakery/httpbakery/_client.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/macaroonbakery/httpbakery/_client.py b/macaroonbakery/httpbakery/_client.py
index 326c33d..230531d 100644
--- a/macaroonbakery/httpbakery/_client.py
+++ b/macaroonbakery/httpbakery/_client.py
@@ -131,7 +131,13 @@ class Client:
# TODO Fabrice what is the other http response possible ??
if resp.status_code == 200:
return bakery.Macaroon.from_dict(resp.json().get('Macaroon'))
- cause = Error.from_dict(resp.json())
+ # A 5xx error might not return json.
+ try:
+ cause = Error.from_dict(resp.json())
+ except ValueError:
+ raise DischargeError(
+ 'unexpected response: [{}] {!r}'.format(resp.status_code, resp.content)
+ )
if cause.code != ERR_INTERACTION_REQUIRED:
raise DischargeError(cause.message)
if cause.info is None: