From 6a5cc42f80f31cdf5d86536ac7100fe5ae957e88 Mon Sep 17 00:00:00 2001 From: Aaron Schaer Date: Mon, 20 Feb 2017 10:38:42 -0600 Subject: [PATCH] Add ValueError catching to exc --- globus_sdk/exc.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) 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