8000 Improve error reporting in the "try_run" function and correctly inclu… · codecov/codecov-python@6638881 · 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.

Commit 6638881

Browse files
Kamithomasrockhu
andauthored
Improve error reporting in the "try_run" function and correctly include original command output in the error message (#153)
* Log more info when a command fails. * Also log return code. * Correctly include process output with the thrown exception. * Include returncode before the output. * Update codecov/__init__.py * black Co-authored-by: Thomas Hu <thomasrockhu@users.noreply.github.com> Co-authored-by: Thomas Hu <tomhu1096@gmail.com>
1 parent bf97a8b commit 6638881

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

codecov/__init__.py

Lines changed: 5 additions & 2 deletions
B1B1
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ def check_output(cmd, **popen_args):
213213
process = Popen(cmd, stdout=PIPE, **popen_args)
214214
output, _ = process.communicate()
215215
if process.returncode:
216-
raise CalledProcessError(process.returncode, cmd)
216+
raise CalledProcessError(process.returncode, cmd, output)
217217
else:
218218
assert process.returncode == 0
219219
return output.decode("utf-8")
@@ -223,7 +223,10 @@ def try_to_run(cmd, shell=False, cwd=None):
223223
try:
224224
return check_output(cmd, shell=shell, cwd=cwd)
225225
except Exception as e:
226-
write(" Error running `%s`: %s" % (cmd, e or str(e)))
226+
write(
227+
" Error running `%s`: returncode=%s, output=%s"
228+
% (cmd, e.returncode, str(getattr(e, "output", str(e))))
229+
)
227230
return None
228231

229232

0 commit comments

Comments
 (0)
0