Skip to content

Commit a61fda2

Browse files
committed
add error handling for client.instance_from_full_uri() method
1 parent 7c759c9 commit a61fda2

1 file changed

Lines changed: 11 additions & 11 deletions

File tree

fairgraph/client.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ def query(
200200
# the following section is a temporary work-around for use during the transitional period
201201
# from openMINDS v3 to v4 (change of namespace)
202202
if self.migrated is None:
203+
# this is the released controlled term for "left handedness", which should be accessible to everyone
203204
result = self.instance_from_full_uri("https://kg.ebrains.eu/api/instances/92631f2e-fc6e-4122-8015-a0731c67f66c", scope="released")
204205
if "om-i.org" in result["@type"]:
205206
self.migrated = True
@@ -344,17 +345,16 @@ def instance_from_full_uri(
344345
else:
345346

346347
def _get_instance(scope):
347-
try:
348-
response = self._kg_client.instances.get_by_id(
349-
stage=STAGE_MAP[scope],
350-
instance_id=self.uuid_from_uri(uri),
351-
extended_response_configuration=default_response_configuration,
352-
)
353-
except Exception as err:
354-
if "404" in str(err):
355-
data = None
356-
else:
357-
raise
348+
response = self._kg_client.instances.get_by_id(
349+
stage=STAGE_MAP[scope],
350+
instance_id=self.uuid_from_uri(uri),
351+
extended_response_configuration=default_response_configuration,
352+
)
353+
error_context = f"_get_instance(scope={scope} uri={uri})"
354+
response = self._check_response(response, error_context=error_context, ignore_not_found=True)
355+
if response.error:
356+
assert response.error.code == 404 # all other errors should have been trapped by the check
357+
data = None
358358
else:
359359
data = response.data
360360
# in some circumstances, the KG returns "minimal" metadata,

0 commit comments

Comments
 (0)