Skip to content

Commit dd1b3a4

Browse files
committed
Fix for error handling of non-JSON responses
1 parent a1703ce commit dd1b3a4

File tree

2 files changed

+2
-10
lines changed

2 files changed

+2
-10
lines changed

dink/client.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ def __call__(self,
6060
path,
6161
params=None,
6262
data=None,
63-
json_type_body=None,
6463
files=None,
6564
download=False
6665
):
@@ -69,9 +68,6 @@ def __call__(self,
6968
# Build headers
7069
headers = {'X-DInk-APIKey': self._api_key}
7170

72-
if json_type_body:
73-
headers['Content-Type'] = 'application/json'
74-
7571
if not download:
7672
headers['Accept'] = 'application/json'
7773

@@ -85,7 +81,6 @@ def __call__(self,
8581
headers=headers,
8682
params=params,
8783
data=data,
88-
json=json_type_body,
8984
files=files,
9085
timeout=self._timeout
9186
)
@@ -115,10 +110,7 @@ def __call__(self,
115110
try:
116111
error = r.json()
117112

118-
except json.decoder.JSONDecodeError:
119-
error = {}
120-
121-
if not isinstance(error, dict):
113+
except ValueError:
122114
error = {}
123115

124116
error_cls = exceptions.DInkException.get_class_by_status_code(

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
# Versions should comply with PEP440. For a discussion on single-sourcing
2222
# the version across setup.py and the project code, see
2323
# https://packaging.python.org/en/latest/single_source_version.html
24-
version='0.0.2',
24+
version='0.0.3',
2525
description=(
2626
'The DInk Python library provides a pythonic interface to the DInk '
2727
'API.',

0 commit comments

Comments
 (0)