From 718627ad2eac0e3831770d28f9fc505d6d8ccd6f Mon Sep 17 00:00:00 2001 From: array-in-a-matrix Date: Mon, 12 Jun 2023 10:20:48 -0400 Subject: [PATCH] error if no config file found --- main.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/main.py b/main.py index 13417c0..9ea5080 100644 --- a/main.py +++ b/main.py @@ -48,14 +48,12 @@ async def main() -> None: global client config = {} - with open('texlily.yaml', 'r') as conf: - config = yaml.safe_load(conf) - if config == None: - print("No config file found. ") - print("") - print("Please create a file named texlily.yaml and read the") - print("README.") - return + try: + with open('texlily.yaml', 'r') as conf: + config = yaml.safe_load(conf) + except FileNotFoundError: + print("No config file found.\nPlease create a file named `texlily.yaml` and read the README file.") + quit() # Retrieve our configuration. homeserver = str(config["homeserver"]) user = str(config["user"])