8000 Improve error reporting in the "try_run" function and correctly include original command output in the error message by Kami · Pull Request #153 · codecov/codecov-python · GitHub
[go: up one dir, main page]

Skip to content
This repository was archived by the owner on May 21, 2025. 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 1 commit
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
Prev Previous commit
Next Next commit
Correctly include process output with the thrown exception.
  • Loading branch information
Kami committed Jul 25, 2018
commit d26470a1daa14b08dc0a10c15f64a6a94d890cdc
6 changes: 3 additions & 3 deletions codecov/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ 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')
Expand All @@ -181,8 +181,8 @@ def try_to_run(cmd):
try:
return check_output(cmd, shell=True)
except subprocess.CalledProcessError as e:
write(' Error running `%s`: output=%s, returncode=%s, e=%s' % (cmd,
str(getattr(e, 'output', '')), e.returncode, str(e)))
write(' Error running `%s`: output=%s, returncode=%s' % (cmd, str(getattr(e, 'output', str(e))),
e.returncode))


def remove_non_ascii(data):
Expand Down
0