From 8307951001354a5cda474f4b718510aea0168906 Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Mon, 8 Feb 2010 21:11:38 +0000 Subject: [PATCH] Catch any/all exceptions from config file parsing --- terminatorlib/config.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/terminatorlib/config.py b/terminatorlib/config.py index 57b29778..468568d2 100755 --- a/terminatorlib/config.py +++ b/terminatorlib/config.py @@ -468,13 +468,17 @@ class ConfigBase(Borg): try: configfile = open(filename, 'r') except Exception, ex: - dbg('ConfigBase::load: Unable to open %s (%s)' % (filename, ex)) + err('ConfigBase::load: Unable to open %s (%s)' % (filename, ex)) return - configspec = self.defaults_to_configspec() - parser = ConfigObj(configfile, configspec=configspec) - validator = Validator() - result = parser.validate(validator, preserve_errors=True) + try: + configspec = self.defaults_to_configspec() + parser = ConfigObj(configfile, configspec=configspec) + validator = Validator() + result = parser.validate(validator, preserve_errors=True) + except Exception, ex: + err('Unable to load configuration: %s' % ex) + return if result != True: err('ConfigBase::load: config format is not valid')