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:
+28
@@ -190,6 +190,10 @@ export class FieldPermissionService {
|
||||
throw new PermissionsException(
|
||||
PermissionsExceptionMessage.ONLY_FIELD_RESTRICTION_ALLOWED,
|
||||
PermissionsExceptionCode.ONLY_FIELD_RESTRICTION_ALLOWED,
|
||||
{
|
||||
userFriendlyMessage:
|
||||
'Field permissions can only be used to restrict access, not to grant additional permissions.',
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@@ -200,6 +204,10 @@ export class FieldPermissionService {
|
||||
throw new PermissionsException(
|
||||
PermissionsExceptionMessage.OBJECT_METADATA_NOT_FOUND,
|
||||
PermissionsExceptionCode.OBJECT_METADATA_NOT_FOUND,
|
||||
{
|
||||
userFriendlyMessage:
|
||||
'The object you are trying to set permissions for could not be found. It may have been deleted.',
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@@ -207,6 +215,10 @@ export class FieldPermissionService {
|
||||
throw new PermissionsException(
|
||||
PermissionsExceptionMessage.CANNOT_ADD_FIELD_PERMISSION_ON_SYSTEM_OBJECT,
|
||||
PermissionsExceptionCode.CANNOT_ADD_FIELD_PERMISSION_ON_SYSTEM_OBJECT,
|
||||
{
|
||||
userFriendlyMessage:
|
||||
'You cannot set field permissions on system objects as they are managed by the platform.',
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@@ -219,6 +231,10 @@ export class FieldPermissionService {
|
||||
throw new PermissionsException(
|
||||
PermissionsExceptionMessage.FIELD_METADATA_NOT_FOUND,
|
||||
PermissionsExceptionCode.FIELD_METADATA_NOT_FOUND,
|
||||
{
|
||||
userFriendlyMessage:
|
||||
'The field you are trying to set permissions for could not be found. It may have been deleted.',
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@@ -229,6 +245,10 @@ export class FieldPermissionService {
|
||||
throw new PermissionsException(
|
||||
PermissionsExceptionMessage.OBJECT_PERMISSION_NOT_FOUND,
|
||||
PermissionsExceptionCode.OBJECT_PERMISSION_NOT_FOUND,
|
||||
{
|
||||
userFriendlyMessage:
|
||||
'No permissions are set for this role on the selected object. Please set object permissions first.',
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -252,6 +272,10 @@ export class FieldPermissionService {
|
||||
throw new PermissionsException(
|
||||
PermissionsExceptionMessage.ROLE_NOT_FOUND,
|
||||
PermissionsExceptionCode.ROLE_NOT_FOUND,
|
||||
{
|
||||
userFriendlyMessage:
|
||||
'The role you are trying to modify could not be found. It may have been deleted or you may not have access to it.',
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@@ -263,6 +287,10 @@ export class FieldPermissionService {
|
||||
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.',
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
+28
@@ -65,6 +65,10 @@ export class ObjectPermissionService {
|
||||
throw new PermissionsException(
|
||||
'Object metadata id not found',
|
||||
PermissionsExceptionCode.OBJECT_METADATA_NOT_FOUND,
|
||||
{
|
||||
userFriendlyMessage:
|
||||
'The object you are trying to set permissions for could not be found. It may have been deleted.',
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@@ -72,6 +76,10 @@ export class ObjectPermissionService {
|
||||
throw new PermissionsException(
|
||||
PermissionsExceptionMessage.CANNOT_ADD_OBJECT_PERMISSION_ON_SYSTEM_OBJECT,
|
||||
PermissionsExceptionCode.CANNOT_ADD_OBJECT_PERMISSION_ON_SYSTEM_OBJECT,
|
||||
{
|
||||
userFriendlyMessage:
|
||||
'You cannot set permissions on system objects as they are managed by the platform.',
|
||||
},
|
||||
);
|
||||
}
|
||||
});
|
||||
@@ -174,6 +182,10 @@ export class ObjectPermissionService {
|
||||
throw new PermissionsException(
|
||||
PermissionsExceptionMessage.CANNOT_GIVE_WRITING_PERMISSION_ON_NON_READABLE_OBJECT,
|
||||
PermissionsExceptionCode.CANNOT_GIVE_WRITING_PERMISSION_ON_NON_READABLE_OBJECT,
|
||||
{
|
||||
userFriendlyMessage:
|
||||
'You cannot grant edit permissions without also granting read permissions. Please enable read access first.',
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -203,6 +215,10 @@ export class ObjectPermissionService {
|
||||
throw new PermissionsException(
|
||||
PermissionsExceptionMessage.ROLE_NOT_FOUND,
|
||||
PermissionsExceptionCode.ROLE_NOT_FOUND,
|
||||
{
|
||||
userFriendlyMessage:
|
||||
'The role you are trying to modify could not be found. It may have been deleted or you may not have access to it.',
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@@ -217,6 +233,10 @@ export class ObjectPermissionService {
|
||||
throw new PermissionsException(
|
||||
PermissionsExceptionMessage.OBJECT_METADATA_NOT_FOUND,
|
||||
PermissionsExceptionCode.OBJECT_METADATA_NOT_FOUND,
|
||||
{
|
||||
userFriendlyMessage:
|
||||
'One or more objects you are trying to set permissions for could not be found. They may have been deleted.',
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -241,6 +261,10 @@ export class ObjectPermissionService {
|
||||
throw new PermissionsException(
|
||||
PermissionsExceptionMessage.ROLE_NOT_FOUND,
|
||||
PermissionsExceptionCode.ROLE_NOT_FOUND,
|
||||
{
|
||||
userFriendlyMessage:
|
||||
'The role you are trying to modify could not be found. It may have been deleted or you may not have access to it.',
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@@ -252,6 +276,10 @@ export class ObjectPermissionService {
|
||||
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.',
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user