]> git.immae.eu Git - perso/Immae/Projets/Python/MusicSampler.git/blobdiff - music_sampler/mapping.py
Improve error message and handling
[perso/Immae/Projets/Python/MusicSampler.git] / music_sampler / mapping.py
index ca471ef7115a3762870c3e5177e996a9c56273af..0d58d3024fc51fb731ce7f39a4bc0432cd410ad3 100644 (file)
@@ -93,8 +93,7 @@ class Mapping(RelativeLayout):
             self.key_config, self.open_files = self.parse_config()
         except Exception as e:
             error_print("Error while loading configuration: {}".format(e),
-                    with_trace=True)
-            sys.exit()
+                    with_trace=True, exit=True)
         else:
             self.success()
 
@@ -306,12 +305,13 @@ class Mapping(RelativeLayout):
         try:
             config = yaml.safe_load(stream)
         except Exception as e:
-            error_print("Error while loading config file: {}".format(e))
-            sys.exit()
+            error_print("Error while loading config file: {}".format(e),
+                    exit=True)
         stream.close()
 
         if not isinstance(config, dict):
-            raise Exception("Top level config is supposed to be a hash")
+            error_print("Top level config is supposed to be a hash",
+                    exit=True)
 
         if 'aliases' in config and isinstance(config['aliases'], dict):
             aliases = config['aliases']