Skip to content
This repository has been archived by the owner on Apr 20, 2023. It is now read-only.

Improve error reporting in the "try_run" function and correctly include original command output in the error message #153

Merged
merged 7 commits into from
Sep 9, 2020
Merged
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions codecov/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,17 +213,18 @@ def check_output(cmd, **popen_args):
process = Popen(cmd, stdout=PIPE, **popen_args)
output, _ = process.communicate()
if process.returncode:
raise CalledProcessError(process.returncode, cmd)
raise CalledProcessError(process.returncode, cmd, output)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

else:
assert process.returncode == 0
return output.decode("utf-8")


def try_to_run(cmd, shell=False, cwd=None):
try:
return check_output(cmd, shell=shell, cwd=cwd)
return check_output(cmd, shell=True, cwd=cwd)
thomasrockhu marked this conversation as resolved.
Show resolved Hide resolved
except Exception as e:
write(" Error running `%s`: %s" % (cmd, e or str(e)))
write(' Error running `%s`: returncode=%s, output=%s' % (cmd, e.returncode,
str(getattr(e, 'output', str(e)))))
return None


Expand Down