1234567891011121314151617 |
- 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<RpcException> {
- catch(exception: RpcException, host: ArgumentsHost): Observable<any> {
- return throwError(() => exception.getError());
- }
- }
|