Catch any/all exceptions from config file parsing
This commit is contained in:
parent
79381c61d0
commit
8307951001
|
@ -468,13 +468,17 @@ class ConfigBase(Borg):
|
||||||
try:
|
try:
|
||||||
configfile = open(filename, 'r')
|
configfile = open(filename, 'r')
|
||||||
except Exception, ex:
|
except Exception, ex:
|
||||||
dbg('ConfigBase::load: Unable to open %s (%s)' % (filename, ex))
|
err('ConfigBase::load: Unable to open %s (%s)' % (filename, ex))
|
||||||
return
|
return
|
||||||
|
|
||||||
|
try:
|
||||||
configspec = self.defaults_to_configspec()
|
configspec = self.defaults_to_configspec()
|
||||||
parser = ConfigObj(configfile, configspec=configspec)
|
parser = ConfigObj(configfile, configspec=configspec)
|
||||||
validator = Validator()
|
validator = Validator()
|
||||||
result = parser.validate(validator, preserve_errors=True)
|
result = parser.validate(validator, preserve_errors=True)
|
||||||
|
except Exception, ex:
|
||||||
|
err('Unable to load configuration: %s' % ex)
|
||||||
|
return
|
||||||
|
|
||||||
if result != True:
|
if result != True:
|
||||||
err('ConfigBase::load: config format is not valid')
|
err('ConfigBase::load: config format is not valid')
|
||||||
|
|
Loading…
Reference in New Issue