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.
This commit is contained in:
logsol 2016-10-09 19:27:10 +02:00
parent dba743cd7b
commit 062402db58

View file

@ -23,7 +23,6 @@ function (Exception) {
this.topics = {}; this.topics = {};
this.subUid = -1; this.subUid = -1;
var i = 0;
this.ns = { this.ns = {
client: { client: {
pointerLock: { pointerLock: {
@ -195,11 +194,14 @@ function (Exception) {
}; };
populate(this.ns); populate(this.ns);
} }
NotificationCenter.prototype.validate = function(topic) { NotificationCenter.prototype.validate = function(topic) {
if (topic === undefined) {
throw new Exception("Topic not registered in Nc. See stack trace.");
}
if (typeof topic === 'object') { if (typeof topic === 'object') {
throw new Exception("Topic bad format " + JSON.stringify(topic)); throw new Exception("Topic bad format " + JSON.stringify(topic));
} }