Closed tyrkinn closed 9 months ago
Interceptor catch errors like "Requested service doesn't have RMQRoute with this path" but not RMQ errors thrown from @RMQRoute
@RMQRoute
My config
imports: [ConfigModule], inject: [ConfigService], useFactory: (configService: ConfigService) => ({ serviceName: configService.get('APP_NAME'), exchangeName: configService.get('EXCHANGE'), prefetchCount: parseInt(configService.get('RMQ_PREFETCH_COUNT')), queueName: configService.get('APP_NAME'), logMessages: process.env.NODE_ENV === 'development', connections: [ { login: configService.get('RMQ_USER'), password: configService.get('RMQ_PASSWORD'), host: configService.get('RMQ_HOST'), port: parseInt(configService.get('RMQ_PORT')), }, ], intercepters: [RMQErrorInterceptor], })
Interceptor:
@Injectable() export class RMQErrorInterceptor extends RMQIntercepterClass { protected logger = new LoggerWithSentry('ERROR INTERCEPTOR'); intercept(res: any, msg: Message, error: Error): Promise<any> { if (error) { this.logger.error(error); } return super.intercept(res, msg, error); } }
Sample handler:
@RMQRoute('sample.route') async handleSample() { console.log('HERE'); throw new RMQError( 'userInfo.internal_server_error', ERROR_TYPE.RMQ, HttpStatus.INTERNAL_SERVER_ERROR, ); }
If i post message on this route, I get 'HERE' in console but error not getting logged
Sorry, just figured out. That was problem on my side
Hello @tyrkinn, just encountered the same problem as you had, could you please describe solution in your case? Thank you.
Interceptor catch errors like "Requested service doesn't have RMQRoute with this path" but not RMQ errors thrown from
@RMQRoute
My config
Interceptor:
Sample handler:
If i post message on this route, I get 'HERE' in console but error not getting logged