Catch MissingPortFile exception (#43573)

This commit is contained in:
Jonah Williams
2019-10-28 10:26:43 -07:00
committed by GitHub
parent d983c1d1ae
commit 36d50a48f4
2 changed files with 23 additions and 0 deletions

View File

@@ -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 {

View File

@@ -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;