UNPKG

@opra/nestjs

Version:
18 lines (17 loc) 756 B
import { Controller } from '@nestjs/common'; import { ExternalExceptionFilter } from '@nestjs/core/exceptions/external-exception-filter.js'; import { classes } from '@opra/common'; const { RpcControllerDecoratorFactory } = classes; const oldCatchMethod = ExternalExceptionFilter.prototype.catch; ExternalExceptionFilter.prototype.catch = function (exception, host) { const opraContext = host.getArgByIndex(3); // Prevents error logging for all Opra controllers if (opraContext && opraContext.request && opraContext.response) throw exception; oldCatchMethod(exception, host); }; RpcControllerDecoratorFactory.augment((decorator, decoratorChain) => { decoratorChain.push((_, target) => { Controller()(target); }); });