From 34843c6a917018620ac3afc9d9e723ddb8617d4c Mon Sep 17 00:00:00 2001 From: clowwindy Date: Mon, 17 Feb 2014 13:27:34 +0800 Subject: [PATCH] better error message with config.json format --- shadowsocks/local.py | 6 +++++- shadowsocks/server.py | 7 ++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/shadowsocks/local.py b/shadowsocks/local.py index 6896eeb..6163c1e 100755 --- a/shadowsocks/local.py +++ b/shadowsocks/local.py @@ -198,7 +198,11 @@ def main(): if config_path: logging.info('loading config from %s' % config_path) 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: config = {} diff --git a/shadowsocks/server.py b/shadowsocks/server.py index f08f841..1224100 100755 --- a/shadowsocks/server.py +++ b/shadowsocks/server.py @@ -150,8 +150,13 @@ def main(): config_path = value if config_path: + logging.info('loading config from %s' % config_path) 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) else: config = {}