src/module/routing/filter/unauthorized.exception.filter.ts
ExceptionFilter
Methods |
catch | |||||||||
catch(exception: UnauthorizedException, host: ArgumentsHost)
|
|||||||||
Parameters :
Returns :
void
|
import { ArgumentsHost, Catch, ExceptionFilter, UnauthorizedException } from '@nestjs/common'
import { UnauthorizedException as ApiUnauthorizedException } from '../../auth/exception/unauthorized.exception'
import { HttpStatus } from '@nestjs/common';
@Catch(UnauthorizedException)
export class UnauthorizedExceptionFilter<T> implements ExceptionFilter {
catch(exception: UnauthorizedException, host: ArgumentsHost) {
const response = host.switchToHttp().getResponse()
response.status(HttpStatus.UNAUTHORIZED).send(new ApiUnauthorizedException())
}
}