import { RpcException } from '@nestjs/microservices' ; import { IExceptionHandler , IExceptionHandlerFactory } from './interfaces' ; import { RpcExceptionHandler } from './impl/RpcExceptionHandler' ; import { InternalExceptionHandler } from './impl/InternalExceptionHandler' ; import { ExceptionType } from '../types' ; export class ExceptionHandlerFactory implements IExceptionHandlerFactory { constructor ( private readonly label ) { } public getHandler ( exception ) { if ( exception instanceof RpcException ) { return new RpcExceptionHandler ( exception ) ; } return new InternalExceptionHandler ( exception , this . label ) ; } }