File

src/module/routing/filter/forbidden.exception.filter.ts

Implements

ExceptionFilter

Index

Methods

Methods

catch
catch(exception: UnauthorizedException, host: ArgumentsHost)
Parameters :
Name Type Optional
exception UnauthorizedException No
host ArgumentsHost No
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())

	}

}

result-matching ""

    No results matching ""