Skip to content

Commit

Permalink
Merge pull request #65 from vrk-kpa/LIKA-589_getOrganization-error-lo…
Browse files Browse the repository at this point in the history
…gging

LIKA-589: More accurate error logging for update_xroad_organizations
  • Loading branch information
bzar authored Feb 26, 2024
2 parents b34ae04 + 2108d16 commit 1df966d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
8 changes: 6 additions & 2 deletions ckanext/xroad_integration/logic/action.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ def _prepare_xroad_organization_patch(organization, last_updated):
organization_dict['old_business_ids'] = old_business_ids

except Exception:
log.warning("Exception")
log.warning("Exception while processing %s (%s)", organization_name, member_code)
raise

return organization_dict
Expand All @@ -269,7 +269,11 @@ def _get_organization_information(business_code):
try:
organization_json = xroad_catalog_query_json('getOrganization', params=[business_code])

if organization_json.get('organizationData') or organization_json.get('companyData'):
if organization_json is None:
error = "XRoad service getOrganization returned an empty response for member {}".format(business_code)
log.warning(error)
raise ContentFetchError(error)
elif organization_json.get('organizationData') or organization_json.get('companyData'):
return organization_json
else:
return None
Expand Down
3 changes: 3 additions & 0 deletions ckanext/xroad_integration/xroad_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ def xroad_catalog_query_json(service, params: List = None, queryparams: Dict[str
if response.status_code == 204:
log.warning("Received empty response for service %s", service)
return
elif response.status_code == 404:
log.warning("Resource not found: %s/%s", service, '/'.join(params))
return
try:
return response.json()
except JSONDecodeError as e:
Expand Down

0 comments on commit 1df966d

Please sign in to comment.