Unverified Commit 36d50a48 authored by Jonah Williams's avatar Jonah Williams Committed by GitHub

Catch MissingPortFile exception (#43573)

parent d983c1d1
...@@ -249,6 +249,10 @@ class ResidentWebRunner extends ResidentRunner { ...@@ -249,6 +249,10 @@ class ResidentWebRunner extends ResidentRunner {
'This can happen if the websocket connection used by the web tooling is ' '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.' '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) { } on SocketException catch (err) {
throwToolExit(err.toString()); throwToolExit(err.toString());
} finally { } finally {
......
...@@ -677,6 +677,25 @@ void main() { ...@@ -677,6 +677,25 @@ void main() {
await expectation; 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 { test('Rethrows unknown exception type from web tooling', () => testbed.run(() async {
_setupMocks(); _setupMocks();
final DelegateLogger delegateLogger = logger; final DelegateLogger delegateLogger = logger;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment