From 0e22996547f4529ec02079846360abcde535a4de Mon Sep 17 00:00:00 2001 From: Aram Kocharyan Date: Thu, 24 Sep 2015 20:37:02 +1000 Subject: [PATCH] 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. --- packages/meteor/dynamics_nodejs.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/meteor/dynamics_nodejs.js b/packages/meteor/dynamics_nodejs.js index 87156cb56c..1037be8e38 100644 --- a/packages/meteor/dynamics_nodejs.js +++ b/packages/meteor/dynamics_nodejs.js @@ -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 */) {