Check type of onException argument to bindEnvironment

Meteor.bindEnvironment() can have an invalid error handler accidentally
passed as the second argument, especially in CoffeeScript where the
issue is not easy to find. This can cause a cryptic error message about
an exception being thrown when onException() itself is being called.
This commit is contained in:
Aram Kocharyan
2015-09-24 20:37:02 +10:00
committed by Avital Oliver
parent e3234ea99f
commit 0e22996547

View File

@@ -94,6 +94,8 @@ Meteor.bindEnvironment = function (func, onException, _this) {
error && error.stack || error
);
};
} else if (typeof(onException) !== 'function') {
throw new Error('onException argument must be a function, string or undefined for Meteor.bindEnvironment().');
}
return function (/* arguments */) {