Skip to content

Commit

Permalink
Improve remote exception printing
Browse files Browse the repository at this point in the history
  • Loading branch information
jdemaeyer committed Feb 29, 2016
1 parent 70601f7 commit 38bc8b7
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion shub/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,14 @@ def make_deploy_request(url, data, files, auth, verbose, keep_log):
if rsp.status_code == 403:
raise InvalidAuthException

msg = "Deploy failed ({}):\n{}".format(rsp.status_code, rsp.text)
try:
error = rsp.json()['message']
if 'Traceback' in error:
error = ('\n---------- REMOTE TRACEBACK ----------\n' + error +
'\n---------- END OF REMOTE TRACEBACK ----------')
except (ValueError, TypeError, KeyError):
error = rsp.text
msg = "Deploy failed ({}):\n{}".format(rsp.status_code, error)
raise RemoteErrorException(msg)
except requests.RequestException as exc:
raise RemoteErrorException("Deploy failed: {}".format(exc))
Expand Down

1 comment on commit 38bc8b7

@pablohoffman
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SGTM

Please sign in to comment.