@@ -6,8 +6,6 @@ import 'dart:async';
6
6
import 'dart:convert' ;
7
7
import 'dart:io' ;
8
8
9
- class SubprocessException implements Exception {}
10
-
11
9
class SubprocessLauncher {
12
10
final String context;
13
11
final Map <String , String > defaultEnvironment;
@@ -121,15 +119,19 @@ class SubprocessLauncher {
121
119
workingDirectory: workingDirectory,
122
120
environment: environment,
123
121
includeParentEnvironment: includeParentEnvironment);
122
+ // Stream stdout and stderr to _this_ process's stdout and stderr.
124
123
var stdoutFuture = _printStream (process.stdout, stdout,
125
124
prefix: prefix, filter: jsonCallback);
126
125
var stderrFuture = _printStream (process.stderr, stderr,
127
126
prefix: prefix, filter: jsonCallback);
128
- await Future .wait ([stderrFuture, stdoutFuture, process.exitCode]);
127
+ var (_, _, exitCode) =
128
+ await (stdoutFuture, stderrFuture, process.exitCode).wait;
129
129
130
- var exitCode = await process.exitCode;
131
130
if (exitCode != 0 ) {
132
- throw SubprocessException ();
131
+ throw SubprocessException (
132
+ command: [executable, ...arguments].join (' ' ),
133
+ workingDirectory: workingDirectory,
134
+ exitCode: exitCode);
133
135
}
134
136
return jsonObjects;
135
137
}
@@ -174,3 +176,21 @@ class SubprocessLauncher {
174
176
175
177
static final _quotables = RegExp (r'[ "\r\n\$]' );
176
178
}
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