File

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

Implements

ExceptionFilter

Index

Methods

Methods

catch
catch(exception: ApiException, host: ArgumentsHost)
Parameters :
Name Type Optional
exception ApiException No
host ArgumentsHost No
Returns : void
import { ArgumentsHost, Catch, ExceptionFilter } from '@nestjs/common'
import { ApiException } from '../exception/api.exception'

@Catch(ApiException)
export class ApiExceptionFilter<T> implements ExceptionFilter {

	catch(exception: ApiException, host: ArgumentsHost) {

		const response = host.switchToHttp().getResponse()

		response.status(exception.http_status_code === undefined ? 500 : exception.http_status_code).send(exception)

	}

}

result-matching ""

    No results matching ""