Catch MissingPortFile exception (#43573)
This commit is contained in:
@@ -249,6 +249,10 @@ class ResidentWebRunner extends ResidentRunner {
|
||||
'This can happen if the websocket connection used by the web tooling is '
|
||||
'unabled to correctly establish a connection, for example due to a firewall.'
|
||||
);
|
||||
} on MissingPortFile {
|
||||
throwToolExit(
|
||||
'Failed to connect to build daemon.\nThe daemon either failed to '
|
||||
'start or was killed by another process.');
|
||||
} on SocketException catch (err) {
|
||||
throwToolExit(err.toString());
|
||||
} finally {
|
||||
|
||||
@@ -677,6 +677,25 @@ void main() {
|
||||
await expectation;
|
||||
}));
|
||||
|
||||
test('Successfully turns MissingPortFile error into ToolExit', () => testbed.run(() async {
|
||||
_setupMocks();
|
||||
final Completer<DebugConnectionInfo> connectionInfoCompleter = Completer<DebugConnectionInfo>();
|
||||
final Completer<void> unhandledErrorCompleter = Completer<void>();
|
||||
when(mockWebFs.connect(any)).thenAnswer((Invocation _) async {
|
||||
unawaited(unhandledErrorCompleter.future.then((void value) {
|
||||
throw MissingPortFile();
|
||||
}));
|
||||
return ConnectionResult(mockAppConnection, mockDebugConnection);
|
||||
});
|
||||
|
||||
final Future<void> expectation = expectLater(() => residentWebRunner.run(
|
||||
connectionInfoCompleter: connectionInfoCompleter,
|
||||
), throwsA(isInstanceOf<ToolExit>()));
|
||||
|
||||
unhandledErrorCompleter.complete();
|
||||
await expectation;
|
||||
}));
|
||||
|
||||
test('Rethrows unknown exception type from web tooling', () => testbed.run(() async {
|
||||
_setupMocks();
|
||||
final DelegateLogger delegateLogger = logger;
|
||||
|
||||
Reference in New Issue
Block a user