diff --git a/ckanext/harvest/harvesters/ckanharvester.py b/ckanext/harvest/harvesters/ckanharvester.py index f041216..0dcb3b4 100644 --- a/ckanext/harvest/harvesters/ckanharvester.py +++ b/ckanext/harvest/harvesters/ckanharvester.py @@ -6,6 +6,7 @@ from ckan.model import Session, Package from ckan.logic import ValidationError, NotFound, get_action from ckan.lib.helpers import json from ckan.lib.munge import munge_name +from simplejson.scanner import JSONDecodeError from ckanext.harvest.model import HarvestJob, HarvestObject, HarvestGatherError, \ HarvestObjectError @@ -221,10 +222,13 @@ class CKANHarvester(HarvesterBase): try: content = self._get_content(url) + package_ids = json.loads(content) except ContentFetchError,e: self._save_gather_error('Unable to get content for URL: %s: %s' % (url, str(e)),harvest_job) return None - package_ids = json.loads(content) + except JSONDecodeError,e: + self._save_gather_error('Unable to decode content for URL: %s: %s' % (url, str(e)),harvest_job) + return None if org_filter_include: package_ids = set(package_ids) & include_pkg_ids