Update user friendly errors for translations (#15000)

Force msg typing instead of string for user friendly errors
This commit is contained in:
Félix Malfait
2025-10-09 18:17:32 +02:00
committed by GitHub
parent 660cd38f35
commit e577c2d746
124 changed files with 796 additions and 563 deletions
@@ -1,6 +1,7 @@
import { Injectable } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import { msg } from '@lingui/core/macro';
import { isDefined } from 'twenty-shared/utils';
import { Repository } from 'typeorm';
@@ -50,8 +51,7 @@ export class PermissionsService {
PermissionsExceptionMessage.NO_ROLE_FOUND_FOR_USER_WORKSPACE,
PermissionsExceptionCode.NO_ROLE_FOUND_FOR_USER_WORKSPACE,
{
userFriendlyMessage:
'Your role in this workspace could not be found. Please contact your workspace administrator.',
userFriendlyMessage: msg`Your role in this workspace could not be found. Please contact your workspace administrator.`,
},
);
}
@@ -135,8 +135,7 @@ export class PermissionsService {
PermissionsExceptionMessage.API_KEY_ROLE_NOT_FOUND,
PermissionsExceptionCode.API_KEY_ROLE_NOT_FOUND,
{
userFriendlyMessage:
'The API key does not have a valid role assigned. Please check your API key configuration.',
userFriendlyMessage: msg`The API key does not have a valid role assigned. Please check your API key configuration.`,
},
);
}
@@ -157,8 +156,7 @@ export class PermissionsService {
PermissionsExceptionMessage.NO_ROLE_FOUND_FOR_USER_WORKSPACE,
PermissionsExceptionCode.NO_ROLE_FOUND_FOR_USER_WORKSPACE,
{
userFriendlyMessage:
'Your role in this workspace could not be found. Please contact your workspace administrator.',
userFriendlyMessage: msg`Your role in this workspace could not be found. Please contact your workspace administrator.`,
},
);
}
@@ -170,8 +168,7 @@ export class PermissionsService {
PermissionsExceptionMessage.NO_AUTHENTICATION_CONTEXT,
PermissionsExceptionCode.NO_AUTHENTICATION_CONTEXT,
{
userFriendlyMessage:
'Authentication is required to access this feature. Please sign in and try again.',
userFriendlyMessage: msg`Authentication is required to access this feature. Please sign in and try again.`,
},
);
}
@@ -1,3 +1,4 @@
import { msg } from '@lingui/core/macro';
import { assertUnreachable } from 'twenty-shared/utils';
import {
@@ -16,12 +17,12 @@ export const permissionGraphqlApiExceptionHandler = (
switch (error.code) {
case PermissionsExceptionCode.PERMISSION_DENIED:
throw new ForbiddenError(error.message, {
userFriendlyMessage: 'User does not have permission.',
userFriendlyMessage: msg`User does not have permission.`,
subCode: error.code,
});
case PermissionsExceptionCode.NO_AUTHENTICATION_CONTEXT:
throw new ForbiddenError(error.message, {
userFriendlyMessage: 'No valid authentication context found.',
userFriendlyMessage: msg`No valid authentication context found.`,
subCode: error.code,
});
case PermissionsExceptionCode.ROLE_LABEL_ALREADY_EXISTS: