Unverified Commit 0dce0c6e authored by Jonah Williams's avatar Jonah Williams Committed by GitHub

catch appInstanceId error from dwds (#42656)

parent b7773da3
......@@ -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();
}
......
......@@ -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>();
......
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