Skip to content

Commit

Permalink
Better handling of HTTP errors upon job submission
Browse files Browse the repository at this point in the history
  • Loading branch information
tmtabor committed Sep 5, 2023
1 parent ee8b24c commit f05b78e
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion gp/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,14 @@ def run_job(self, job_spec, wait_until_done=True):
request.add_header('Authorization', self.authorization_header())
request.add_header('Content-Type', 'application/json')
request.add_header('User-Agent', 'GenePatternRest')
response = urllib.request.urlopen(request, json_string)
try:
response = urllib.request.urlopen(request, json_string)
except urllib.error.HTTPError as e:
if e.code == 403:
print("job POST failed, your account is either over the data limit or you have too many jobs running")
else:
print(f" job POST failed, status code = {e.code}, {e.reason}")
return None
if response.getcode() != 201:
print(" job POST failed, status code = %i" % response.getcode())
return None
Expand Down

0 comments on commit f05b78e

Please sign in to comment.