import { Catch, RpcExceptionFilter, ArgumentsHost } from '@nestjs/common'; import { Observable, throwError } from 'rxjs'; import { BaseRpcExceptionFilter, RpcException } from '@nestjs/microservices'; @Catch() export class AllExceptionsFilter extends BaseRpcExceptionFilter { catch(exception: any, host: ArgumentsHost) { return super.catch(exception, host); } } @Catch(RpcException) export class ExceptionFilter implements RpcExceptionFilter { catch(exception: RpcException, host: ArgumentsHost): Observable { return throwError(() => exception.getError()); } }