add userFriendly messages to PermissionsException (#13659)

/closes #13580

<img width="1186" height="754" alt="image"
src="https://github.com/user-attachments/assets/d5be9e3a-2748-4ad0-b29b-98038cbeeb6a"
/>
This commit is contained in:
neo773
2025-08-06 02:11:51 +05:30
committed by GitHub
parent 22eedb0281
commit a804d65210
11 changed files with 148 additions and 0 deletions
@@ -85,6 +85,10 @@ export class RoleResolver {
throw new PermissionsException(
PermissionsExceptionMessage.CANNOT_UPDATE_SELF_ROLE,
PermissionsExceptionCode.CANNOT_UPDATE_SELF_ROLE,
{
userFriendlyMessage:
'You cannot change your own role. Please ask another administrator to update your role.',
},
);
}
@@ -122,6 +122,10 @@ export class RoleService {
throw new PermissionsException(
PermissionsExceptionMessage.ROLE_NOT_FOUND,
PermissionsExceptionCode.ROLE_NOT_FOUND,
{
userFriendlyMessage:
'The role you are looking for could not be found. It may have been deleted or you may not have access to it.',
},
);
}
@@ -185,6 +189,10 @@ export class RoleService {
throw new PermissionsException(
PermissionsExceptionMessage.DEFAULT_ROLE_NOT_FOUND,
PermissionsExceptionCode.DEFAULT_ROLE_NOT_FOUND,
{
userFriendlyMessage:
'The default role for this workspace could not be found. Please contact support for assistance.',
},
);
}
@@ -283,6 +291,10 @@ export class RoleService {
throw new PermissionsException(
error.message,
PermissionsExceptionCode.INVALID_ARG,
{
userFriendlyMessage:
'Some of the information provided is invalid. Please check your input and try again.',
},
);
}
}
@@ -346,6 +358,10 @@ export class RoleService {
throw new PermissionsException(
PermissionsExceptionMessage.CANNOT_GIVE_WRITING_PERMISSION_WITHOUT_READING_PERMISSION,
PermissionsExceptionCode.CANNOT_GIVE_WRITING_PERMISSION_WITHOUT_READING_PERMISSION,
{
userFriendlyMessage:
'You cannot grant edit permissions without also granting read permissions. Please enable read access first.',
},
);
}
}
@@ -401,6 +417,10 @@ export class RoleService {
throw new PermissionsException(
PermissionsExceptionMessage.ROLE_NOT_EDITABLE,
PermissionsExceptionCode.ROLE_NOT_EDITABLE,
{
userFriendlyMessage:
'This role cannot be modified because it is a system role. Only custom roles can be edited.',
},
);
}
}
@@ -416,6 +436,10 @@ export class RoleService {
throw new PermissionsException(
PermissionsExceptionMessage.DEFAULT_ROLE_CANNOT_BE_DELETED,
PermissionsExceptionCode.DEFAULT_ROLE_CANNOT_BE_DELETED,
{
userFriendlyMessage:
'The default role cannot be deleted as it is required for the workspace to function properly.',
},
);
}
}