Skip to content

There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.

feat: log all exceptions In HTTP context (#4149)

X1a0ted76417ba361
diff --git a/apps/server/src/middleware/exception-logger.ts b/apps/server/src/middleware/exception-logger.ts
index 79497acfdd..cec7eaecc6 100644
--- a/apps/server/src/middleware/exception-logger.ts
+++ b/apps/server/src/middleware/exception-logger.ts
@@ -9,11 +9,12 @@ import { Request, Response } from 'express';
import { REQUEST_ID } from '../constants';
-@Catch(HttpException)
+@Catch()
export class ExceptionLogger implements ExceptionFilter {
private logger = new Logger('ExceptionLogger');
catch(exception: Error, host: ArgumentsHost) {
+ // with useGlobalFilters, the context is always HTTP
const ctx = host.switchToHttp();
const request = ctx.getRequest<Request>();
const requestId = request?.header(REQUEST_ID);
@@ -27,11 +28,11 @@ export class ExceptionLogger implements ExceptionFilter {
const response = ctx.getResponse<Response>();
if (exception instanceof HttpException) {
- response.json(exception.getResponse());
+ response.status(exception.getStatus()).json(exception.getResponse());
} else {
response.status(500).json({
- message: exception.message,
statusCode: 500,
+ error: exception.message,
});
}
}