diff --git a/packages/nocodb/src/filters/global-exception/global-exception.filter.ts b/packages/nocodb/src/filters/global-exception/global-exception.filter.ts index ac9b6e5692..7f8ac8adc5 100644 --- a/packages/nocodb/src/filters/global-exception/global-exception.filter.ts +++ b/packages/nocodb/src/filters/global-exception/global-exception.filter.ts @@ -8,6 +8,7 @@ import { NotFound, NotImplemented, Unauthorized, + UnprocessableEntity, } from '../../helpers/catchError'; import type { ArgumentsHost, ExceptionFilter } from '@nestjs/common'; import type { Response } from 'express'; @@ -15,6 +16,7 @@ import type { Response } from 'express'; @Catch() export class GlobalExceptionFilter implements ExceptionFilter { private logger = new Logger(GlobalExceptionFilter.name); + catch(exception: any, host: ArgumentsHost) { const ctx = host.switchToHttp(); const response = ctx.getResponse(); @@ -58,6 +60,8 @@ export class GlobalExceptionFilter implements ExceptionFilter { return response .status(400) .json({ msg: exception.message, errors: exception.errors }); + } else if (exception instanceof UnprocessableEntity) { + return response.status(422).json({ msg: exception.message }); } // handle different types of exceptions