Skip to content

Commit

Permalink
permissions: change error handler for resolving pid permission denied
Browse files Browse the repository at this point in the history
  • Loading branch information
anikachurilova authored and monotasker committed Aug 19, 2024
1 parent f27d98b commit c8e7f9c
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion invenio_rdm_records/services/pids/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
from invenio_drafts_resources.services.records import RecordService
from invenio_pidstore.errors import PIDDoesNotExistError
from invenio_pidstore.models import PersistentIdentifier
from invenio_records_resources.services.errors import (
PermissionDeniedError,
RecordPermissionDeniedError,
)
from invenio_records_resources.services.uow import RecordCommitOp, unit_of_work
from invenio_requests.services.results import EntityResolverExpandableField
from sqlalchemy.orm.exc import NoResultFound
Expand Down Expand Up @@ -83,7 +87,10 @@ def resolve(self, identity, id_, scheme, expand=False):
if record is None:
raise PIDDoesNotExistError(scheme, id_)

self.require_permission(identity, "read", record=record)
try:
self.require_permission(identity, "read", record=record)
except PermissionDeniedError:
raise RecordPermissionDeniedError(action_name="read", record=record)

return self.result_item(
self,
Expand Down

0 comments on commit c8e7f9c

Please sign in to comment.