Skip to content

Commit 7b59b80

Browse files
martmullWeiko
authored andcommitted
Fix unhandled exception (#5474)
Solves exception.getStatus is not a function error logs in twenty-server Catch all errors in order to have no error log at all
1 parent 9e3420d commit 7b59b80

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

packages/twenty-server/src/utils/apply-cors-to-exceptions.ts

+10-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
import { ExceptionFilter, Catch, ArgumentsHost } from '@nestjs/common';
1+
import {
2+
ExceptionFilter,
3+
Catch,
4+
ArgumentsHost,
5+
HttpException,
6+
} from '@nestjs/common';
27

38
import { Response } from 'express';
49

@@ -25,6 +30,9 @@ export class ApplyCorsToExceptions implements ExceptionFilter {
2530
'Origin, X-Requested-With, Content-Type, Accept',
2631
);
2732

28-
response.status(exception.getStatus()).json(exception.response);
33+
const status =
34+
exception instanceof HttpException ? exception.getStatus() : 500;
35+
36+
response.status(status).json(exception.response);
2937
}
3038
}

0 commit comments

Comments
 (0)