Add exception handling for the API version parsing
I have added try-except clauses in order to prevent the process from crashing if a non-parsable integer is used for the api_version option. Signed-off-by: Konrad Reiche <konrad.reiche@fokus.fraunhofer.de>
This commit is contained in:
parent
05094090af
commit
c858b9fe9f
|
@ -130,7 +130,11 @@ class HarvesterBase(SingletonPlugin):
|
|||
|
||||
# Check API version
|
||||
if self.config:
|
||||
try:
|
||||
api_version = int(self.config.get('api_version', 2))
|
||||
except ValueError:
|
||||
raise ValueError('api_version must be an integer')
|
||||
|
||||
#TODO: use site user when available
|
||||
user_name = self.config.get('user', u'harvest')
|
||||
else:
|
||||
|
|
|
@ -53,7 +53,10 @@ class CKANHarvester(HarvesterBase):
|
|||
self.config = json.loads(config_str)
|
||||
|
||||
if 'api_version' in self.config:
|
||||
try:
|
||||
self.api_version = int(self.config['api_version'])
|
||||
except ValueError:
|
||||
raise ValueError('api_version must be an integer')
|
||||
|
||||
log.debug('Using config: %r', self.config)
|
||||
else:
|
||||
|
|
Loading…
Reference in New Issue