From fdb8037c1207d21fd5c233cc771237e20f494ec7 Mon Sep 17 00:00:00 2001 From: Armaan Bhojwani Date: Sun, 31 Jan 2021 15:39:01 -0500 Subject: [PATCH] Make file not found exception prettier --- lightcards/parse.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lightcards/parse.py b/lightcards/parse.py index fb5ac68..d0b0eb5 100755 --- a/lightcards/parse.py +++ b/lightcards/parse.py @@ -11,8 +11,12 @@ from .deck import Card def md2html(file): """Use the markdown module to convert input to HTML""" - with open(file, "r", encoding="utf-8") as input_file: - return markdown.markdown(input_file.read(), extensions=['tables']) + try: + with open(file, "r", encoding="utf-8") as input_file: + return markdown.markdown(input_file.read(), extensions=['tables']) + except FileNotFoundError: + print(f"File \"{file}\" not found!") + exit(1) def parse_html(html): -- 2.39.2