diff options
author | Kristian Lyngstol <kly@kly.no> | 2019-02-22 09:19:38 +0100 |
---|---|---|
committer | Kristian Lyngstol <kly@kly.no> | 2019-02-22 09:19:38 +0100 |
commit | d41b6089eb98b8bdc5c46b0a7fe07c47184ac923 (patch) | |
tree | c77a2421b8afc652d293cc8905003fe5fff6b116 /web/js/nms-map-handlers.js | |
parent | 5f28425a4285cadcaf4309aed482a97e9017d0de (diff) |
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.
Diffstat (limited to 'web/js/nms-map-handlers.js')
-rw-r--r-- | web/js/nms-map-handlers.js | 10 |
1 files changed, 7 insertions, 3 deletions
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; } |