report error if failed process captures stderr (#9293)
When a Spack Executable was configured to capture stderr and the process failed, the error messages of the process were discarded. This made it difficult to understand why the process failed. The exception is now updated to include the stderr of the process when the Executable captures stderr.
This commit is contained in:
parent
7b2b2fb969
commit
95850a7a5e
@ -186,18 +186,28 @@ def streamify(arg, mode):
|
||||
env=env)
|
||||
out, err = proc.communicate()
|
||||
|
||||
rc = self.returncode = proc.returncode
|
||||
if fail_on_error and rc != 0 and (rc not in ignore_errors):
|
||||
raise ProcessError('Command exited with status %d:' %
|
||||
proc.returncode, cmd_line)
|
||||
|
||||
result = None
|
||||
if output is str or error is str:
|
||||
result = ''
|
||||
if output is str:
|
||||
result += to_str(out)
|
||||
if error is str:
|
||||
result += to_str(err)
|
||||
return result
|
||||
|
||||
rc = self.returncode = proc.returncode
|
||||
if fail_on_error and rc != 0 and (rc not in ignore_errors):
|
||||
long_msg = cmd_line
|
||||
if result:
|
||||
# If the output is not captured in the result, it will have
|
||||
# been stored either in the specified files (e.g. if
|
||||
# 'output' specifies a file) or written to the parent's
|
||||
# stdout/stderr (e.g. if 'output' is not specified)
|
||||
long_msg += '\n' + result
|
||||
|
||||
raise ProcessError('Command exited with status %d:' %
|
||||
proc.returncode, long_msg)
|
||||
|
||||
return result
|
||||
|
||||
except OSError as e:
|
||||
raise ProcessError(
|
||||
|
Loading…
Reference in New Issue
Block a user