diff --git a/globus_sdk/exc.py b/globus_sdk/exc.py index 9bcecc86e..f0005d560 100644 --- a/globus_sdk/exc.py +++ b/globus_sdk/exc.py @@ -31,7 +31,7 @@ def __init__(self, r, *args, **kw): 'Doing error load from JSON')) try: self._load_from_json(r.json()) - except KeyError: + except (KeyError, ValueError): logger.error(('Error body could not be JSON decoded! ' 'This means the Content-Type is wrong, or the ' 'body is malformed!')) @@ -56,7 +56,13 @@ def raw_json(self): r = self._underlying_response if "Content-Type" in r.headers and ( "application/json" in r.headers["Content-Type"]): - return r.json() + try: + return r.json() + except ValueError: + logger.error(('Error body could not be JSON decoded! ' + 'This means the Content-Type is wrong, or the ' + 'body is malformed!')) + return None else: return None