From 851d863652303b3a597c1dec990bea89f2327418 Mon Sep 17 00:00:00 2001 From: "David Humphrey (:humph) david.humphrey@senecacollege.ca" Date: Mon, 18 Aug 2014 19:21:35 -0400 Subject: [PATCH] A few fixes --- src/errors.js | 16 ++++++++-------- tests/spec/errors.spec.js | 4 ++-- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/errors.js b/src/errors.js index d7ec802..21e6112 100644 --- a/src/errors.js +++ b/src/errors.js @@ -73,15 +73,15 @@ var errors = {}; '1002:ENOATTR:attribute does not exist' ].forEach(function(e) { e = e.split(':'); - var errno = e[0]|0, - err = e[1], - message = e[2]; + var errno = +e[0]; + var errName = e[1]; + var defaultMessage = e[2]; function FilerError(msg, path) { - this.name = err; - this.code = err; + this.name = errName; + this.code = errName; this.errno = errno; - this.message = msg || message; + this.message = msg || defaultMessage; if(path) { this.path = path; } @@ -90,11 +90,11 @@ var errors = {}; FilerError.prototype.constructor = FilerError; FilerError.prototype.toString = function() { var pathInfo = this.path ? (', \'' + this.path + '\'') : ''; - return this.name + ': ' + message + pathInfo; + return this.name + ': ' + this.message + pathInfo; }; // We expose the error as both Errors.EINVAL and Errors[18] - errors[err] = errors[errno] = FilerError; + errors[errName] = errors[errno] = FilerError; }); module.exports = errors; diff --git a/tests/spec/errors.spec.js b/tests/spec/errors.spec.js index cc9ec9c..ca034cd 100644 --- a/tests/spec/errors.spec.js +++ b/tests/spec/errors.spec.js @@ -165,11 +165,11 @@ describe("Filer.Errors", function() { it('should not include path in toString() when not provided', function() { var err = new Filer.Errors.ENOENT('This is the message'); - expect(err.toString()).to.equal("ENOENT: no such file or directory"); + expect(err.toString()).to.equal("ENOENT: This is the message"); }); it('should include path in toString() when provided', function() { - var err = new Filer.Errors.ENOENT('This is the message', '/this/is/the/path'); + var err = new Filer.Errors.ENOENT(null, '/this/is/the/path'); expect(err.toString()).to.equal("ENOENT: no such file or directory, '/this/is/the/path'"); });