From b758b3887b37d53c80c6c13243c941c0870cb7ed Mon Sep 17 00:00:00 2001 From: dw-0 Date: Sat, 22 Jun 2024 10:54:11 +0200 Subject: [PATCH] refactor: improve error logging on missing kiauh config file Signed-off-by: Dominik Willner --- kiauh/core/settings/kiauh_settings.py | 21 ++++++++++----------- kiauh/utils/logger.py | 12 ++++++++---- 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/kiauh/core/settings/kiauh_settings.py b/kiauh/core/settings/kiauh_settings.py index 904dd69..9aa84d3 100644 --- a/kiauh/core/settings/kiauh_settings.py +++ b/kiauh/core/settings/kiauh_settings.py @@ -212,15 +212,14 @@ class KiauhSettings: ) def _kill(self) -> None: - l1 = "!!! ERROR !!!" - l2 = "No KIAUH configuration file found!" - error = textwrap.dedent( - f""" - {COLOR_RED}/=======================================================\\ - | {l1:^53} | - | {l2:^53} | - \=======================================================/{RESET_FORMAT} - """ - )[1:] - print(error, end="") + Logger.print_dialog( + DialogType.ERROR, + [ + "No KIAUH configuration file found! Please make sure you have at least " + "one of the following configuration files in KIAUH's root directory:", + "● default.kiauh.cfg", + "● kiauh.cfg", + ], + end="", + ) kill() diff --git a/kiauh/utils/logger.py b/kiauh/utils/logger.py index e8ba0a4..ef25ee5 100644 --- a/kiauh/utils/logger.py +++ b/kiauh/utils/logger.py @@ -120,15 +120,19 @@ class Logger: @staticmethod def _format_top_border(color: str) -> str: - return textwrap.dedent(f""" + return textwrap.dedent( + f""" {color}┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓ - """)[:-1] + """ + )[1:-1] @staticmethod def _format_bottom_border() -> str: - return textwrap.dedent(f""" + return textwrap.dedent( + f""" ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛ - {RESET_FORMAT}""") + {RESET_FORMAT}""" + ) @staticmethod def _format_dialog_title(title: str) -> str: