I'm extending Error object here and passing the status code, code and the message.
class AuthenticationException extends Error {
constructor(statusCode, code, message) {
super();
this.statusCode = statusCode;
this.message = message;
this.code = code;
}
}
export default AuthenticationException;
But the Error throws only like below
{
"error": "Unable to decode token"
}
But this is not what i was looking for. The result should be like,
{
"message": "Unable to decode token",
"code":1234
}
Please help me If you can. And can I get many key-value pair as throw exception?