catch appInstanceId error from dwds (#42656)

This commit is contained in:
Jonah Williams 2019-10-14 17:28:28 -07:00 committed by GitHub
parent b7773da37b
commit 0dce0c6e30
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 0 deletions

View file

@ -213,6 +213,13 @@ class ResidentWebRunner extends ResidentRunner {
throwToolExit('Failed to build application for the Web.');
} on SocketException catch (err) {
throwToolExit(err.toString());
} on StateError catch (err) {
// Handle known state error.
final String message = err.toString();
if (message.contains('Could not connect to application with appInstanceId')) {
throwToolExit(message);
}
rethrow;
} finally {
buildStatus.stop();
}

View file

@ -480,6 +480,25 @@ void main() {
await expectation;
}));
test('Successfully turns AppInstanceId 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 StateError('Could not connect to application with appInstanceId: c0ae0750-ee91-11e9-cea6-35d95a968356');
}));
return ConnectionResult(mockAppConnection, mockDebugConnection);
});
final Future<void> expectation = expectLater(() => residentWebRunner.run(
connectionInfoCompleter: connectionInfoCompleter,
), throwsA(isInstanceOf<ToolExit>()));
unhandledErrorCompleter.complete();
await expectation;
}));
test('Rethrows Exception type', () => testbed.run(() async {
_setupMocks();
final Completer<DebugConnectionInfo> connectionInfoCompleter = Completer<DebugConnectionInfo>();