File

src/module/routing/filter/unauthorized.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 } 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())

	}

}

result-matching ""

    No results matching ""