mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
catch VMService connection exception (#6526)
This commit is contained in:
parent
0b49d81cb2
commit
ca90656fba
@ -25,7 +25,12 @@ class VMService {
|
||||
/// Connect to '127.0.0.1' at [port].
|
||||
static Future<VMService> connect(int port) async {
|
||||
Uri uri = new Uri(scheme: 'ws', host: '127.0.0.1', port: port, path: 'ws');
|
||||
WebSocket ws = await WebSocket.connect(uri.toString());
|
||||
WebSocket ws;
|
||||
try {
|
||||
ws = await WebSocket.connect(uri.toString());
|
||||
} catch (e) {
|
||||
return new Future<VMService>.error('Failed to connect to $uri\n $e');
|
||||
}
|
||||
rpc.Peer peer = new rpc.Peer(new IOWebSocketChannel(ws).cast());
|
||||
peer.listen();
|
||||
Uri httpAddress = new Uri(scheme: 'http', host: '127.0.0.1', port: port);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user