Merge pull request #244 from humphd/better-errors

Fix crash in src/errors.js, see https://github.com/mozilla/makedrive/issues/145
This commit is contained in:
Alan K 2014-07-24 12:48:52 -04:00
commit e9eae3549b
1 changed files with 7 additions and 6 deletions

View File

@ -77,16 +77,17 @@ var errors = {};
err = e[1], err = e[1],
message = e[2]; message = e[2];
function ctor(m) { function FilerError(m) {
this.name = err;
this.code = err;
this.errno = errno;
this.message = m || message; this.message = m || message;
} }
var proto = ctor.prototype = new Error(); FilerError.prototype = Object.create(Error.prototype);
proto.errno = errno; FilerError.prototype.constructor = FilerError;
proto.code = err;
proto.constructor = ctor;
// We expose the error as both Errors.EINVAL and Errors[18] // We expose the error as both Errors.EINVAL and Errors[18]
errors[err] = errors[errno] = ctor; errors[err] = errors[errno] = FilerError;
}); });
module.exports = errors; module.exports = errors;