Skip to content

Commit f99e3fc

Browse files
author
Rich Leland
committed
Catch more than JSON parsing errors
1 parent 8fe7c84 commit f99e3fc

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

sparkpost/exceptions.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,14 @@ class SparkPostException(Exception):
55
class SparkPostAPIException(SparkPostException):
66
"Handle 4xx and 5xx errors from the SparkPost API"
77
def __init__(self, response, *args, **kwargs):
8-
errors = None
98
try:
109
errors = response.json()['errors']
1110
error_template = "{message} Code: {code} Description: {desc} \n"
1211
errors = [error_template.format(message=e['message'],
1312
code=e.get('code', 'none'),
1413
desc=e.get('description', 'none'))
1514
for e in errors]
16-
except ValueError:
15+
except:
1716
errors = [response.text or ""]
1817
self.status = response.status_code
1918
self.response = response

0 commit comments

Comments
 (0)