mirror of
https://github.com/flutter/flutter
synced 2024-10-13 03:32:55 +00:00
Catch AppConnectionException from dwds (#43544)
This commit is contained in:
parent
be53209e82
commit
553662d101
|
@ -234,15 +234,14 @@ class ResidentWebRunner extends ResidentRunner {
|
|||
throwToolExit(
|
||||
'Failed to establish connection with Chrome. Try running the application again.\n'
|
||||
'If this problem persists, please file an issue with the details below:\n$err\n$stackTrace');
|
||||
} on AppConnectionException {
|
||||
throwToolExit(
|
||||
'Failed to establish connection with the application instance in Chrome.\n'
|
||||
'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 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 {
|
||||
if (statusActive) {
|
||||
buildStatus.stop();
|
||||
|
|
|
@ -565,13 +565,13 @@ void main() {
|
|||
await expectation;
|
||||
}));
|
||||
|
||||
test('Successfully turns AppInstanceId error into ToolExit', () => testbed.run(() async {
|
||||
test('Successfully turns AppConnectionException 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');
|
||||
throw AppConnectionException('Could not connect to application with appInstanceId: c0ae0750-ee91-11e9-cea6-35d95a968356');
|
||||
}));
|
||||
return ConnectionResult(mockAppConnection, mockDebugConnection);
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue