Skip to main content

UnauthorizedException

How To use UnauthorizedException ?

Status Code 401

Usage

With custom configuration

...
if (isNotAuthorized) {
throw new UnauthorizedException({
code: 'UNAUTHORIZED',
message: 'You are not authorized'
});
}
...

With default configuration

...
if (isNotAuthorized) {
throw new UnauthorizedException();
}
...
/*
output:
{
message: 'Unauthorized',
code: 'UNAUTHORIZED'
}
*/