Verbose process exceptions (#61552)

This commit is contained in:
Christopher Fujino
2020-07-16 11:31:03 -07:00
committed by GitHub
parent 9ef8192760
commit f796e047fd
5 changed files with 70 additions and 13 deletions

View File

@@ -226,6 +226,7 @@ class _PosixUtils extends OperatingSystemUtils {
_processUtils.runSync(
<String>['unzip', '-o', '-q', file.path, '-d', targetDirectory.path],
throwOnError: true,
verboseExceptions: true,
);
}

View File

@@ -231,6 +231,7 @@ abstract class ProcessUtils {
RunResult runSync(
List<String> cmd, {
bool throwOnError = false,
bool verboseExceptions = false,
RunResultChecker allowedFailures,
bool hideStdout = false,
String workingDirectory,
@@ -408,6 +409,7 @@ class _DefaultProcessUtils implements ProcessUtils {
RunResult runSync(
List<String> cmd, {
bool throwOnError = false,
bool verboseExceptions = false,
RunResultChecker allowedFailures,
bool hideStdout = false,
String workingDirectory,
@@ -449,7 +451,12 @@ class _DefaultProcessUtils implements ProcessUtils {
}
if (failedExitCode && throwOnError) {
runResult.throwException('The command failed');
String message = 'The command failed';
if (verboseExceptions) {
message = 'The command failed\nStdout:\n${runResult.stdout}\n'
'Stderr:\n${runResult.stderr}';
}
runResult.throwException(message);
}
return runResult;