From 9d704e80c9dec4a8b92f3bb9f1d22035e11003f8 Mon Sep 17 00:00:00 2001 From: "David Humphrey (:humph) david.humphrey@senecacollege.ca" Date: Thu, 24 Jul 2014 12:24:47 -0400 Subject: [PATCH] Fix crash in src/errors.js, see https://github.com/mozilla/makedrive/issues/145 --- src/errors.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/errors.js b/src/errors.js index 8a6c585..fbb5e96 100644 --- a/src/errors.js +++ b/src/errors.js @@ -77,16 +77,17 @@ var errors = {}; err = e[1], message = e[2]; - function ctor(m) { + function FilerError(m) { + this.name = err; + this.code = err; + this.errno = errno; this.message = m || message; } - var proto = ctor.prototype = new Error(); - proto.errno = errno; - proto.code = err; - proto.constructor = ctor; + FilerError.prototype = Object.create(Error.prototype); + FilerError.prototype.constructor = FilerError; // We expose the error as both Errors.EINVAL and Errors[18] - errors[err] = errors[errno] = ctor; + errors[err] = errors[errno] = FilerError; }); module.exports = errors;