better error message with config.json format

This commit is contained in:
clowwindy 2014-02-17 13:27:34 +08:00
parent f81d735b5b
commit 34843c6a91
2 changed files with 11 additions and 2 deletions

View file

@ -198,7 +198,11 @@ def main():
if config_path: if config_path:
logging.info('loading config from %s' % config_path) logging.info('loading config from %s' % config_path)
with open(config_path, 'rb') as f: with open(config_path, 'rb') as f:
config = json.load(f) try:
config = json.load(f)
except ValueError as e:
logging.error('found an error in config.json: %s', e.message)
sys.exit(1)
else: else:
config = {} config = {}

View file

@ -150,8 +150,13 @@ def main():
config_path = value config_path = value
if config_path: if config_path:
logging.info('loading config from %s' % config_path)
with open(config_path, 'rb') as f: with open(config_path, 'rb') as f:
config = json.load(f) try:
config = json.load(f)
except ValueError as e:
logging.error('found an error in config.json: %s', e.message)
sys.exit(1)
logging.info('loading config from %s' % config_path) logging.info('loading config from %s' % config_path)
else: else:
config = {} config = {}