Skip to content

Commit

Permalink
revert this later
Browse files Browse the repository at this point in the history
  • Loading branch information
supalarry committed Oct 17, 2024
1 parent ac72ee3 commit 2d04256
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
2 changes: 2 additions & 0 deletions apps/api/v2/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import "./instrument";

import { HttpExceptionFilter } from "@/filters/http-exception.filter";
import { PrismaExceptionFilter } from "@/filters/prisma-exception.filter";
import { TestExceptionFilter } from "@/filters/test-filter";
import { ZodExceptionFilter } from "@/filters/zod-exception.filter";
import type { ValidationError } from "@nestjs/common";
import { BadRequestException, ValidationPipe, VersioningType } from "@nestjs/common";
Expand Down Expand Up @@ -78,6 +79,7 @@ export const bootstrap = (app: NestExpressApplication): NestExpressApplication =
app.useGlobalFilters(new ZodExceptionFilter());
app.useGlobalFilters(new HttpExceptionFilter());
app.useGlobalFilters(new TRPCExceptionFilter());
app.useGlobalFilters(new TestExceptionFilter());

app.use(cookieParser());

Expand Down
22 changes: 22 additions & 0 deletions apps/api/v2/src/filters/test-filter.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { ArgumentsHost, Catch, ExceptionFilter, Logger } from "@nestjs/common";
import { Request } from "express";

import { Response } from "@calcom/platform-types";

@Catch()
export class TestExceptionFilter implements ExceptionFilter {
private readonly logger = new Logger("TRPCExceptionFilter");

catch(exception: Error, host: ArgumentsHost) {
const ctx = host.switchToHttp();
const request = ctx.getRequest<Request>();

this.logger.error(`Test Exception Filter: ${exception?.message}`, {
exception: JSON.stringify(exception, null, 2),
body: request.body,
headers: request.headers,
url: request.url,
method: request.method,
});
}
}

0 comments on commit 2d04256

Please sign in to comment.