Skip to content

Commit

Permalink
Get the first holding, error if more than one found
Browse files Browse the repository at this point in the history
  • Loading branch information
nmassey001 committed Jan 14, 2025
1 parent db90182 commit 2d87b1d
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion nlds_processors/catalog/catalog_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,11 +370,23 @@ def _get_or_create_holding(
holding = self.catalog.get_holding(user, group, label=new_label)
except (KeyError, CatalogError):
holding = self.catalog.create_holding(user, group, new_label)
else:
if len(holding) > 1:
raise CatalogError(
f"More than one holding found for label {new_label}"
)
else:
holding = holding[0]
except CatalogError as e:
self.log(e.message, RK.LOG_ERROR)
raise e
else:
holding = holding[0]
if len(holding) > 1:
raise CatalogError(
f"More than one holding found for label {new_label}"
)
else:
holding = holding[0]
return holding

def _get_or_create_transaction(self, transaction_id, holding):
Expand Down

0 comments on commit 2d87b1d

Please sign in to comment.