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 82e9eff..dd3056e 100644 --- a/test/authorizer.test.js +++ b/test/authorizer.test.js @@ -17,6 +17,7 @@ describe('authorizer', function () { socket.on('error', function(err){ err.should.eql("jwt malformed"); + err.code.should.eql("invalid_token"); done(); }); });