From b1a019bfe6c43a9adce3b7191c8c44a05e32acd4 Mon Sep 17 00:00:00 2001 From: antonyscerri Date: Sat, 24 Nov 2018 08:41:35 +0000 Subject: [PATCH] Websocket error handler (#54) * Fix to handle no data in websocket response and call callback or default handler * Added handling of non 2XX websocket response codes as errors --- scripts/graphioGremlin.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/scripts/graphioGremlin.js b/scripts/graphioGremlin.js index acb7a02..401044e 100644 --- a/scripts/graphioGremlin.js +++ b/scripts/graphioGremlin.js @@ -306,6 +306,12 @@ var graphioGremlin = (function(){ }; ws.onmessage = function (event){ var response = JSON.parse(event.data); + var code=Number(response.status.code) + if(!isInt(code) || code<200 || code>299) { + $('#outputArea').html(response.status.message); + $('#messageArea').html("Error retrieving data"); + return 1; + } var data = response.result.data; if (data == null){ if (query_type == 'editGraph'){