From 139843467b80a4dab9b4ea9d1a399e74abd7c348 Mon Sep 17 00:00:00 2001 From: Vadim Kazakov Date: Wed, 16 Jul 2014 14:12:18 -0600 Subject: [PATCH] add data to UnauthorizedError so that more information can be returned to client --- lib/UnauthorizedError.js | 6 +++++- test/authorizer.test.js | 3 ++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/UnauthorizedError.js b/lib/UnauthorizedError.js index 2ff9999..ca197bc 100644 --- a/lib/UnauthorizedError.js +++ b/lib/UnauthorizedError.js @@ -1,8 +1,12 @@ function UnauthorizedError (code, error) { Error.call(this, error.message); this.message = error.message; - this.code = code; this.inner = error; + this.data = { + message: this.message, + code: code, + type: "UnauthorizedError" + }; } UnauthorizedError.prototype = Object.create(Error.prototype); diff --git a/test/authorizer.test.js b/test/authorizer.test.js index 8890dfb..fa188ed 100644 --- a/test/authorizer.test.js +++ b/test/authorizer.test.js @@ -16,7 +16,8 @@ describe('authorizer', function () { }); socket.on('error', function(err){ - err.should.eql("Invalid token: no header in signature 'boooooo'"); + err.message.should.eql("Invalid token: no header in signature 'boooooo'"); + err.code.should.eql("invalid_token"); done(); }); });