From d41b6089eb98b8bdc5c46b0a7fe07c47184ac923 Mon Sep 17 00:00:00 2001 From: Kristian Lyngstol Date: Fri, 22 Feb 2019 09:19:38 +0100 Subject: front: Handle corrupt tag-json more gracefully Caused a problem locally after I had accidentally made tags into an object instead of an array during testing, but this CAN happen if someone writes {} instead of [], so better to anticipate it. --- web/js/nms-map-handlers.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'web') diff --git a/web/js/nms-map-handlers.js b/web/js/nms-map-handlers.js index d553fc0..f5f072b 100644 --- a/web/js/nms-map-handlers.js +++ b/web/js/nms-map-handlers.js @@ -873,10 +873,14 @@ function memoryInfo(sw) { } function tagged(sw, tag) { - if (testTree(nmsData,['switches','switches',sw, 'tags'])) { - if (nmsData.switches.switches[sw].tags.includes(tag)) { - return true; + try { + if (testTree(nmsData,['switches','switches',sw, 'tags'])) { + if (nmsData.switches.switches[sw].tags.includes(tag)) { + return true; + } } + } catch(e) { + console.log("Tried to find tags for " + sw + "but tags-datastructure is probably not an array?"); } return false; } -- cgit v1.2.3