]> git.armaanb.net Git - lightcards.git/blobdiff - lightcards/parse.py
Make file not found exception prettier
[lightcards.git] / 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):