Skip to content

Commit

Permalink
Merge pull request #7 from creynders/patch-2
Browse files Browse the repository at this point in the history
Expose `isError`
  • Loading branch information
bodenr committed Aug 14, 2014
2 parents 482430d + 9652630 commit 00c8f58
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
PROJECT := $(realpath $(dir $(lastword $(MAKEFILE_LIST))))
PROJECT := "$(realpath $(dir $(lastword $(MAKEFILE_LIST))))"
MD_PATH := $(PROJECT)/doc/md/
HTML_PATH := $(PROJECT)/doc/html/
NODE_BIN := $(PROJECT)/node_modules/.bin/
Expand Down
2 changes: 1 addition & 1 deletion lib/errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ exports.find = function(err) {
* @api private
*/

function isError(err) {
var isError = exports.isError = function isError(err) {
return err && err.hasOwnProperty('explanation') && err.hasOwnProperty('code');
};

Expand Down
12 changes: 12 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -247,4 +247,16 @@ describe('status code override', function() {
it('should allow overriding in constructor', function() {
new CustomHttpError({status:411}).status.should.equal(411);
});
});

describe('errors.isError()', function(){
var legitError = new errors.HttpError();

it('should return true for legit errors', function() {
errors.isError(legitError).should.be.ok;
});

it('should return false for other objects', function() {
errors.isError({}).should.not.be.ok;
});
});

0 comments on commit 00c8f58

Please sign in to comment.