[flutter_tools] Fix Future error handling ArgumentError in doctor --android-licenses (#119977)

* wip

* write test

* make error handling printError

* remove diff
This commit is contained in:
Christopher Fujino
2023-02-04 23:06:19 -08:00
committed by GitHub
parent 2e39badf98
commit b8f5394a5c
2 changed files with 53 additions and 7 deletions

View File

@@ -436,11 +436,14 @@ class AndroidLicenseValidator extends DoctorValidator {
unawaited(process.stdin.addStream(_stdio.stdin)
// If the process exits unexpectedly with an error, that will be
// handled by the caller.
.catchError((dynamic err, StackTrace stack) {
_logger.printTrace('Echoing stdin to the licenses subprocess failed:');
_logger.printTrace('$err\n$stack');
}
));
.then(
(Object? socket) => socket,
onError: (dynamic err, StackTrace stack) {
_logger.printError('Echoing stdin to the licenses subprocess failed:');
_logger.printError('$err\n$stack');
},
),
);
// Wait for stdout and stderr to be fully processed, because process.exitCode
// may complete first.
@@ -450,8 +453,8 @@ class AndroidLicenseValidator extends DoctorValidator {
_stdio.addStderrStream(process.stderr),
]);
} on Exception catch (err, stack) {
_logger.printTrace('Echoing stdout or stderr from the license subprocess failed:');
_logger.printTrace('$err\n$stack');
_logger.printError('Echoing stdout or stderr from the license subprocess failed:');
_logger.printError('$err\n$stack');
}
final int exitCode = await process.exitCode;