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