import { CallHandler , ExecutionContext , HttpException , HttpStatus , Injectable , NestInterceptor } from '@nestjs/common' ; import { Observable , throwError } from 'rxjs' ; import { catchError } from 'rxjs/operators' ; @ Injectable ( ) export class ErrorsInterceptor implements NestInterceptor { intercept ( context , next ) { return next . handle ( ) . pipe ( catchError ( err => throwError ( new HttpException ( 'New message' , HttpStatus . BAD_GATEWAY ) ) ) ) ; } }