From 62c70402c6645423836644dffa68349e720ed1b2 Mon Sep 17 00:00:00 2001 From: Sandra Serrano <69241131+sandrasgg@users.noreply.github.com> Date: Wed, 23 Aug 2023 15:47:23 +0200 Subject: [PATCH] Exit the system instead of raising Exception --- utils/settings.py | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/utils/settings.py b/utils/settings.py index 3987557..418ba34 100755 --- a/utils/settings.py +++ b/utils/settings.py @@ -112,16 +112,14 @@ def check_toml(template_file, config_file) -> dict: template = toml.load(template_file) except Exception as error: console.print(f"[red bold]Encountered error when trying to to load {template_file}: {error}") - raise + sys.exit() try: config = toml.load(config_file) except toml.TomlDecodeError: - console.print( - f"""[blue]Couldn't read {config_file}. Overwrite it?(y/n)""" - ) + console.print(f"""[blue]Couldn't read {config_file}. Overwrite it?(y/n)""") if not input().startswith("y"): print("Unable to read config, and not allowed to overwrite it. Giving up.") - raise + sys.exit() else: try: with open(config_file, "w") as f: @@ -131,11 +129,9 @@ def check_toml(template_file, config_file) -> dict: f"[red bold]Failed to overwrite {config_file}. Giving up." f"\nSuggestion: check {config_file} permissions for the user." ) - raise + sys.exit() except FileNotFoundError: - console.print( - f"""[blue]Couldn't find {config_file} Creating it now.""" - ) + console.print(f"""[blue]Couldn't find {config_file} Creating it now.""") try: with open(config_file, "x") as f: f.write("") @@ -145,7 +141,7 @@ def check_toml(template_file, config_file) -> dict: f"[red bold]Failed to write to {config_file}. Giving up." f"\nSuggestion: check the folder's permissions for the user." ) - raise + sys.exit() console.print( """\