Skip to content

Commit

Permalink
fix: better debug for missing related resources
Browse files Browse the repository at this point in the history
  • Loading branch information
philtweir committed Jun 15, 2024
1 parent af63310 commit aa68f03
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion arches_orm/view_models/resources.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import uuid
import logging
from collections import UserList
from arches.app.models.resource import Resource
from ._base import ViewModel, ResourceInstanceViewModel


Expand Down Expand Up @@ -39,7 +41,16 @@ def append(self, item: str | uuid.UUID | ResourceInstanceViewModel):
resource_instance_id = item["resourceId"]
# TODO: why no error on else?

value, _, __, ___ = self._make_ri_cb(resource_instance or resource_instance_id)
try:
value, _, __, ___ = self._make_ri_cb(resource_instance or resource_instance_id)
except Resource.DoesNotExist as exc:
logging.error(
"Tried to load %s for %s but could not: %s",
str(resource_instance or resource_instance_id),
str(self._parent_wkri.id if self._parent_wkri else "(unknown)"),
str(exc)
)
value = None

if not value:
raise RuntimeError(f"Could not append {item} to resource list within {self._parent_wkri}")
Expand Down

0 comments on commit aa68f03

Please sign in to comment.