From 376864d6d15817acc8c3f9a647da58638cf2b499 Mon Sep 17 00:00:00 2001 From: Samuel Mannehed Date: Sat, 5 Nov 2016 18:18:15 +0100 Subject: [PATCH] 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". --- core/rfb.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/core/rfb.js b/core/rfb.js index e3238241..5b1579a8 100644 --- a/core/rfb.js +++ b/core/rfb.js @@ -372,7 +372,15 @@ uri += '://' + this._rfb_host + ':' + this._rfb_port + '/' + this._rfb_path; Util.Info("connecting to " + uri); - this._sock.open(uri, this._wsProtocols); + try { + 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"); },