Fix unclear metadata validation errors (#20234)
https://github.com/user-attachments/assets/8f8f1122-3de1-4a9b-8bb4-a3c8d31e47ae --------- Co-authored-by: Cursor <cursoragent@cursor.com> Co-authored-by: Charles Bochet <charles@twenty.com>
This commit is contained in:
+2
-7
@@ -1,5 +1,3 @@
|
||||
import { type I18n } from '@lingui/core';
|
||||
|
||||
import { UserInputError } from 'src/engine/core-modules/graphql/utils/graphql-errors.util';
|
||||
import {
|
||||
ViewGroupException,
|
||||
@@ -7,10 +5,7 @@ import {
|
||||
} from 'src/engine/metadata-modules/view-group/exceptions/view-group.exception';
|
||||
import { viewGraphqlApiExceptionHandler } from 'src/engine/metadata-modules/view/utils/view-graphql-api-exception-handler.util';
|
||||
|
||||
export const viewGroupGraphqlApiExceptionHandler = (
|
||||
error: Error,
|
||||
i18n: I18n,
|
||||
) => {
|
||||
export const viewGroupGraphqlApiExceptionHandler = (error: Error) => {
|
||||
if (error instanceof ViewGroupException) {
|
||||
if (
|
||||
error.code ===
|
||||
@@ -22,5 +17,5 @@ export const viewGroupGraphqlApiExceptionHandler = (
|
||||
}
|
||||
}
|
||||
|
||||
return viewGraphqlApiExceptionHandler(error, i18n);
|
||||
return viewGraphqlApiExceptionHandler(error);
|
||||
};
|
||||
|
||||
+2
-13
@@ -4,11 +4,7 @@ import {
|
||||
type ExecutionContext,
|
||||
Injectable,
|
||||
} from '@nestjs/common';
|
||||
import { GqlExecutionContext } from '@nestjs/graphql';
|
||||
|
||||
import { SOURCE_LOCALE } from 'twenty-shared/translations';
|
||||
|
||||
import { I18nService } from 'src/engine/core-modules/i18n/i18n.service';
|
||||
import { ViewGroupException } from 'src/engine/metadata-modules/view-group/exceptions/view-group.exception';
|
||||
import { viewGroupGraphqlApiExceptionHandler } from 'src/engine/metadata-modules/view-group/utils/view-group-graphql-api-exception-handler.util';
|
||||
import { WorkspaceMigrationBuilderException } from 'src/engine/workspace-manager/workspace-migration/exceptions/workspace-migration-builder-exception';
|
||||
@@ -16,17 +12,10 @@ import { WorkspaceMigrationBuilderException } from 'src/engine/workspace-manager
|
||||
@Catch(ViewGroupException, WorkspaceMigrationBuilderException)
|
||||
@Injectable()
|
||||
export class ViewGroupGraphqlApiExceptionFilter implements ExceptionFilter {
|
||||
constructor(private readonly i18nService: I18nService) {}
|
||||
|
||||
catch(
|
||||
exception: ViewGroupException | WorkspaceMigrationBuilderException,
|
||||
host: ExecutionContext,
|
||||
_host: ExecutionContext,
|
||||
) {
|
||||
const gqlContext = GqlExecutionContext.create(host);
|
||||
const ctx = gqlContext.getContext();
|
||||
const userLocale = ctx.req?.locale ?? SOURCE_LOCALE;
|
||||
const i18n = this.i18nService.getI18nInstance(userLocale);
|
||||
|
||||
return viewGroupGraphqlApiExceptionHandler(exception, i18n);
|
||||
return viewGroupGraphqlApiExceptionHandler(exception);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user