Update user friendly errors for translations (#15000)
Force msg typing instead of string for user friendly errors
This commit is contained in:
+5
-8
@@ -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.`,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
+3
-2
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user