Skip to content

Commit a78ecbe

Browse files
committed
Update ClientError and ServerError methods
1 parent ae2a07f commit a78ecbe

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

lib/createsend/createsend.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,9 +229,11 @@ def handle_response(self, status, data):
229229
elif status == 404:
230230
raise NotFound()
231231
elif status in range(400, 500):
232-
raise ClientError()
232+
json_data = json_to_py(data)
233+
raise ClientError(f"Code: {json_data.Code} {json_data.Message}")
233234
elif status in range(500, 600):
234-
raise ServerError()
235+
json_data = json_to_py(data)
236+
raise ServerError(f"Code: {json_data.Code} {json_data.Message}")
235237
return data
236238

237239
def _get(self, path, params={}, username=None, password=None):

0 commit comments

Comments
 (0)