src/module/routing/filter/api.exception.filter.ts
ExceptionFilter
Methods |
catch | |||||||||
catch(exception: ApiException, host: ArgumentsHost)
|
|||||||||
Parameters :
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)
}
}