Skip to content

Commit d541b7b

Browse files
author
Shariq Hashme
committed
improved error handling
1 parent 55b621f commit d541b7b

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

scaleapi/__init__.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,10 @@ def _getrequest(self, endpoint, params={}):
5959
return r.json()
6060
else:
6161
try:
62-
raise ScaleException(r.json()['error'], r.status_code)
62+
error = r.json()['error']
6363
except ValueError:
64-
pass
65-
raise ScaleException(r.text, r.status_code)
64+
error = r.text
65+
raise ScaleException(error, r.status_code)
6666

6767
def _postrequest(self, endpoint, payload=None):
6868
"""Makes a post request to an endpoint.
@@ -80,10 +80,10 @@ def _postrequest(self, endpoint, payload=None):
8080
return r.json()
8181
else:
8282
try:
83-
raise ScaleException(r.json()['error'], r.status_code)
83+
error = r.json()['error']
8484
except ValueError:
85-
pass
86-
raise ScaleException(r.text, r.status_code)
85+
error = r.text
86+
raise ScaleException(error, r.status_code)
8787

8888
def fetch_task(self, task_id):
8989
"""Fetches a task.

0 commit comments

Comments
 (0)