9953: If config cannot be read/parsed, show just the error without the stack trace.
authorTom Clegg <tom@curoverse.com>
Wed, 28 Sep 2016 13:44:07 +0000 (09:44 -0400)
committerTom Clegg <tom@curoverse.com>
Wed, 28 Sep 2016 20:02:08 +0000 (16:02 -0400)
services/dockercleaner/arvados_docker/cleaner.py

index 9dd7b12a08b7b45b50b018aa1a8c59a6aa8beed6..8b8c772e542adfb6decaa7be501dcafab8db91a5 100755 (executable)
@@ -257,8 +257,12 @@ def load_config(arguments):
     args = parse_arguments(arguments)
 
     config = default_config()
-    with open(args.config, 'r') as f:
-        config.update(json.load(f))
+    try:
+        with open(args.config, 'r') as f:
+            c = json.load(f)
+            config.update(c)
+    except (FileNotFoundError, IOError, ValueError) as error:
+        sys.exit('error reading config file {}: {}'.format(args.config, error))
 
     configargs = vars(args).copy()
     configargs.pop('config')