2
1
mirror of https://github.com/Thream/socketio-jwt.git synced 2024-07-21 09:38:31 +02:00

add data to UnauthorizedError so that more information can be returned to client

This commit is contained in:
Vadim Kazakov 2014-07-16 14:12:18 -06:00
parent 870a274be9
commit 139843467b
2 changed files with 7 additions and 2 deletions

View File

@ -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);

View File

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