Catch JSONDecodeError when no JSON content
This commit is contained in:
parent
6415cdd740
commit
084723abb7
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue