]> git.armaanb.net Git - lightcards.git/commitdiff
Make file not found exception prettier
authorArmaan Bhojwani <me@armaanb.net>
Sun, 31 Jan 2021 20:39:01 +0000 (15:39 -0500)
committerArmaan Bhojwani <me@armaanb.net>
Sun, 31 Jan 2021 20:39:01 +0000 (15:39 -0500)
lightcards/parse.py

index fb5ac68a2195bd9ccfdb1109c912bd1f83158b59..d0b0eb5c001e19cf98f64c7aa1c5d8675f7bdeda 100755 (executable)
@@ -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):