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(); }); });