Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions dspace_rest_client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,9 @@ def fetch_resource(self, url, params=None):
"""
r = self.api_get(url, params, None)
if r.status_code != 200:
# record the failing response so callers can tell a 404 (the
# resource is gone) from a transient 5xx before we drop the body
self._last_err = r
_logger.error(f'Error encountered fetching resource: {r.text}')
return None
# ValueError / JSON handling moved to static method
Expand Down Expand Up @@ -698,6 +701,12 @@ def get_bundles(self, parent=None, uuid=None, page=0, size=20, sort=None):
if sort is not None:
params['sort'] = sort
r_json = self.fetch_resource(url, params=params)
if r_json is None and getattr(self._last_err, 'status_code', None) == 404:
# the item (or bundle) no longer exists - a deleted item simply has
# no bundles, which is a clean empty result, not a crash. any other
# failure falls through and still surfaces to the caller.
_logger.info(f'No bundles: resource not found (404) [{url}]')
return bundles
try:
if single_result:
bundles.append(Bundle(r_json))
Expand Down