import { ArgumentsHost , Catch , ExceptionFilter , HttpException } from '@nestjs/common' ; @ Catch ( HttpException ) export class HttpExceptionFilter implements ExceptionFilter < HttpException > { catch ( exception , host ) { const ctx = host . switchToHttp ( ) ; const response = ctx . getResponse ( ) ; const request = ctx . getRequest ( ) ; const statusCode = exception . getStatus ( ) ; response . status ( statusCode ) . json ( { statusCode , timestamp : new Date ( ) . toISOString ( ) , path : request . url } ) ; } }