Provide exception information when reading config
This commit is contained in:
parent
fd08ddacd3
commit
56d8d05e77
2 changed files with 8 additions and 2 deletions
|
@ -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
4
dotbot/util/string.py
Normal 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)))
|
Loading…
Reference in a new issue