From 062402db588f4308cb5898c78206be3dc6057756 Mon Sep 17 00:00:00 2001 From: logsol Date: Sun, 9 Oct 2016 19:27:10 +0200 Subject: [PATCH] Adds NotificationCenter exception when triggering unknown topic If you forget to add a certain topic to the Nc, you will now get an Exception with a meaningful message. --- app/Lib/Utilities/NotificationCenter.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/Lib/Utilities/NotificationCenter.js b/app/Lib/Utilities/NotificationCenter.js index 33b4be2..d629b8e 100755 --- a/app/Lib/Utilities/NotificationCenter.js +++ b/app/Lib/Utilities/NotificationCenter.js @@ -23,7 +23,6 @@ function (Exception) { this.topics = {}; this.subUid = -1; - var i = 0; this.ns = { client: { pointerLock: { @@ -195,11 +194,14 @@ function (Exception) { }; populate(this.ns); - } NotificationCenter.prototype.validate = function(topic) { + if (topic === undefined) { + throw new Exception("Topic not registered in Nc. See stack trace."); + } + if (typeof topic === 'object') { throw new Exception("Topic bad format " + JSON.stringify(topic)); }