From 9d2033504f54713b0ed22d1448fef498eabdccb2 Mon Sep 17 00:00:00 2001 From: Louis Date: Mon, 28 Apr 2014 09:58:14 +0200 Subject: [PATCH] Message d'erreur plus clair en cas d'erreur json dans les fichiers.sb --- songbook | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/songbook b/songbook index 9a814474..678e243e 100755 --- a/songbook +++ b/songbook @@ -100,8 +100,14 @@ def main(): basename = os.path.basename(songbook_path)[:-3] - with open(songbook_path) as songbook_file: - songbook = json.load(songbook_file) + try: + with open(songbook_path) as songbook_file: + songbook = json.load(songbook_file) + except Exception as error: # pylint: disable=broad-except + LOGGER.error(error) + LOGGER.error("Error while loading file '{}'.".format(songbook_path)) + sys.exit(1) + if options.datadir is not None: songbook['datadir'] = options.datadir[0]