diff --git a/ckanext/xroad_integration/logic/action.py b/ckanext/xroad_integration/logic/action.py index 0d64a96..939c061 100644 --- a/ckanext/xroad_integration/logic/action.py +++ b/ckanext/xroad_integration/logic/action.py @@ -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 @@ -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 diff --git a/ckanext/xroad_integration/xroad_utils.py b/ckanext/xroad_integration/xroad_utils.py index 3851f7c..4221bba 100644 --- a/ckanext/xroad_integration/xroad_utils.py +++ b/ckanext/xroad_integration/xroad_utils.py @@ -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: