Catch error if missing config

This commit is contained in:
Jake Howard 2017-03-30 16:19:31 +01:00
parent 18f041c07c
commit 5114f83b5d

View file

@ -2,8 +2,12 @@ import yaml
from dotmap import DotMap from dotmap import DotMap
import os import os
from md_pdf.consts import CONFIG_FILE from md_pdf.consts import CONFIG_FILE
from md_pdf.exceptions import ConfigValidationException
def load_config(): def load_config():
try:
with open(os.path.join(CONFIG_FILE)) as f: with open(os.path.join(CONFIG_FILE)) as f:
return DotMap(yaml.load(f)) return DotMap(yaml.load(f))
except FileNotFoundError:
raise ConfigValidationException("Can't find config file at {}".format(CONFIG_FILE))