mirror of
1
0
Fork 0

Provide exception information when reading config

This commit is contained in:
Joshua Blum 2015-04-24 12:47:42 +03:00 committed by Anish Athalye
parent fd08ddacd3
commit 56d8d05e77
2 changed files with 8 additions and 2 deletions

View File

@ -1,4 +1,5 @@
import yaml
from .util import string
class ConfigReader(object):
def __init__(self, config_file_path):
@ -9,8 +10,9 @@ class ConfigReader(object):
with open(config_file_path) as fin:
data = yaml.load(fin)
return data
except Exception:
raise ReadingError('Could not read config file')
except Exception as e:
msg = string.indent_lines(str(e))
raise ReadingError('Could not read config file:\n%s' % msg)
def get_config(self):
return self._config

4
dotbot/util/string.py Normal file
View File

@ -0,0 +1,4 @@
def indent_lines(string, amount=2, delimiter='\n'):
whitespace = ' ' * amount
sep = '%s%s' % (delimiter, whitespace)
return '%s%s' % (whitespace, sep.join(string.split(delimiter)))