diff --git a/packages/meteor/errors.js b/packages/meteor/errors.js index cf2777dab8..dfff723900 100644 --- a/packages/meteor/errors.js +++ b/packages/meteor/errors.js @@ -4,26 +4,19 @@ // Meteor.makeErrorType = function (name, constructor) { var errorClass = function (/*arguments*/) { - var self = this; - // Ensure we get a proper stack trace in most Javascript environments if (Error.captureStackTrace) { // V8 environments (Chrome and Node.js) - Error.captureStackTrace(self, errorClass); + Error.captureStackTrace(this, errorClass); } else { - // Firefox - var e = new Error; - e.__proto__ = errorClass.prototype; - if (e instanceof errorClass) - self = e; + // Borrow the .stack property of a native Error object. + this.stack = new Error().stack; } // Safari magically works. - constructor.apply(self, arguments); + constructor.apply(this, arguments); - self.errorType = name; - - return self; + this.errorType = name; }; Meteor._inherits(errorClass, Error);