Skip to content

Commit cd0b47a

Browse files
committed
Merge pull request #155 from peterjc/shed_upload_errors
Not all exceptions will have a .read() method.
2 parents 6893f3a + cd049b4 commit cd0b47a

1 file changed

Lines changed: 13 additions & 9 deletions

File tree

planemo/commands/cmd_shed_upload.py

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -96,16 +96,20 @@ def __handle_upload(ctx, realized_repository, **kwds):
9696
try:
9797
tsi.repositories.update_repository(repo_id, tar_path, **update_kwds)
9898
except Exception as e:
99-
exception_content = e.read()
100-
try:
101-
# Galaxy passes nice JSON messages as their errors, which bioblend
102-
# blindly returns. Attempt to parse those.
103-
upstream_error = json.loads(exception_content)
104-
error(upstream_error['err_msg'])
105-
except Exception as e2:
99+
if hasattr(e, "read"):
100+
exception_content = e.read()
101+
try:
102+
# Galaxy passes nice JSON messages as their errors, which bioblend
103+
# blindly returns. Attempt to parse those.
104+
upstream_error = json.loads(exception_content)
105+
error(upstream_error['err_msg'])
106+
except Exception as e2:
107+
error("Could not update %s" % realized_repository.name)
108+
error(exception_content)
109+
error(e2.read())
110+
else:
106111
error("Could not update %s" % realized_repository.name)
107-
error(exception_content)
108-
error(e2.read())
112+
error(str(e))
109113
return -1
110114
info("Repository %s updated successfully." % realized_repository.name)
111115
return 0

0 commit comments

Comments
 (0)