@opra/nestjs-http
Version:
Opra NestJS Http Module
25 lines (24 loc) • 882 B
JavaScript
import { __decorate, __metadata } from "tslib";
import { Catch } from '@nestjs/common';
import { BaseExceptionFilter, ModuleRef } from '@nestjs/core';
import { OpraHttpNestjsAdapter } from './opra-http-nestjs-adapter.js';
let OpraExceptionFilter = class OpraExceptionFilter extends BaseExceptionFilter {
constructor(moduleRef) {
super();
this.moduleRef = moduleRef;
}
catch(exception, host) {
const ctx = host.switchToHttp().getRequest().opraContext;
if (ctx) {
const adapter = this.moduleRef.get(OpraHttpNestjsAdapter);
ctx.errors.push(exception);
return adapter.handler.sendResponse(ctx);
}
super.catch(exception, host);
}
};
OpraExceptionFilter = __decorate([
Catch(),
__metadata("design:paramtypes", [ModuleRef])
], OpraExceptionFilter);
export { OpraExceptionFilter };