Skip to content
This repository has been archived by the owner on Jan 13, 2024. It is now read-only.

Commit

Permalink
better error message for run_cmd
Browse files Browse the repository at this point in the history
  • Loading branch information
sdpython committed Dec 20, 2016
1 parent 5702218 commit 1a36c57
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
7 changes: 5 additions & 2 deletions src/pyquickhelper/helpgen/sphinx_main_helper.py
Expand Up @@ -337,8 +337,11 @@ def compile_latex_output_final(root, latex_path, doall, afile=None, latex_book=F
lat, file, build)
fLOG("~~~~ LATEX compilation (c)", c)
post_process_latex_output(file, doall, latex_book=latex_book)
out, err = run_cmd(c, wait=True, log_error=False, catch_exit=True, communicate=False,
tell_if_no_output=120, fLOG=fLOG)
try:
out, err = run_cmd(c, wait=True, log_error=False, catch_exit=True, communicate=False,
tell_if_no_output=120, fLOG=fLOG)
except Exception as e:
raise OSError("Unable to execute\n{0}".format(c)) from e
if len(err) > 0:
raise HelpGenException(
"CMD:\n{0}\nERR:\n{1}\nOUT:\n{2}".format(c, err, out))
Expand Down
4 changes: 2 additions & 2 deletions src/pyquickhelper/loghelper/run_cmd.py
Expand Up @@ -336,8 +336,8 @@ def run_cmd(cmd, sin="", shell=sys.platform.startswith("win"), wait=False, log_e
except Exception as e:
warnings.warn("Unable to close stdout and sterr.")
if catch_exit:
raise RunCmdException("SystemExit raised with error code {0}\nOUT:\n{1}\nERR:\n{2}".format(
returnCode, "\n".join(out), "\n".join(err)))
raise RunCmdException("SystemExit raised with error code {0}\nCMD:\n{1}\nCWD:\n{2}\nOUT:\n{3}\nERR:\n{4}".format(
returnCode, cmd, os.getcwd(), "\n".join(out), "\n".join(err)))
else:
raise subprocess.CalledProcessError(returnCode, cmd)

Expand Down

0 comments on commit 1a36c57

Please sign in to comment.