Handle errors while opening a Websocket

For example, previously if the user typed in illegal characters in the
port field, no error would be displayed in the interface and the page
would stop at "connecting".
This commit is contained in:
Samuel Mannehed 2016-11-05 18:18:15 +01:00
parent d24de750b1
commit 376864d6d1
1 changed files with 9 additions and 1 deletions

View File

@ -372,7 +372,15 @@
uri += '://' + this._rfb_host + ':' + this._rfb_port + '/' + this._rfb_path; uri += '://' + this._rfb_host + ':' + this._rfb_port + '/' + this._rfb_path;
Util.Info("connecting to " + uri); Util.Info("connecting to " + uri);
try {
this._sock.open(uri, this._wsProtocols); this._sock.open(uri, this._wsProtocols);
} catch (e) {
if (e.name === 'SyntaxError') {
this._fail("Invalid host or port value given");
} else {
this._fail("Error while opening websocket (" + e + ")");
}
}
Util.Debug("<< RFB.connect"); Util.Debug("<< RFB.connect");
}, },