@@ -6,8 +6,6 @@ import 'dart:async';
66import 'dart:convert' ;
77import 'dart:io' ;
88
9- class SubprocessException implements Exception {}
10-
119class SubprocessLauncher {
1210 final String context;
1311 final Map <String , String > defaultEnvironment;
@@ -121,15 +119,19 @@ class SubprocessLauncher {
121119 workingDirectory: workingDirectory,
122120 environment: environment,
123121 includeParentEnvironment: includeParentEnvironment);
122+ // Stream stdout and stderr to _this_ process's stdout and stderr.
124123 var stdoutFuture = _printStream (process.stdout, stdout,
125124 prefix: prefix, filter: jsonCallback);
126125 var stderrFuture = _printStream (process.stderr, stderr,
127126 prefix: prefix, filter: jsonCallback);
128- await Future .wait ([stderrFuture, stdoutFuture, process.exitCode]);
127+ var (_, _, exitCode) =
128+ await (stdoutFuture, stderrFuture, process.exitCode).wait;
129129
130- var exitCode = await process.exitCode;
131130 if (exitCode != 0 ) {
132- throw SubprocessException ();
131+ throw SubprocessException (
132+ command: [executable, ...arguments].join (' ' ),
133+ workingDirectory: workingDirectory,
134+ exitCode: exitCode);
133135 }
134136 return jsonObjects;
135137 }
@@ -174,3 +176,21 @@ class SubprocessLauncher {
174176
175177 static final _quotables = RegExp (r'[ "\r\n\$]' );
176178}
179+
180+ /// An exception that represents an issue during subprocess execution.
181+ class SubprocessException implements Exception {
182+ final String command;
183+ final String ? workingDirectory;
184+ final int exitCode;
185+
186+ SubprocessException (
187+ {required this .command,
188+ required this .workingDirectory,
189+ required this .exitCode});
190+
191+ @override
192+ String toString () => 'SubprocessException['
193+ 'command: "$command ", '
194+ 'workingDirectory: "${workingDirectory ?? '(null)' }", '
195+ 'exitCode: $exitCode ]' ;
196+ }
0 commit comments