Raise FileNoteFoundError on Note init if applicable
authorAdam Dullage <redacted>
Wed, 22 Nov 2023 13:04:36 +0000 (13:04 +0000)
committerAdam Dullage <redacted>
Wed, 22 Nov 2023 13:04:36 +0000 (13:04 +0000)
flatnotes/flatnotes.py

index f3e71cb56433b389694fbbe7858e1415544abf03..526ad325b775d2c27856407c1bb8a56476980159 100644 (file)
@@ -49,9 +49,12 @@ class Note:
         self._title = title.strip()
         if not is_valid_filename(self._title):
             raise InvalidTitleError
-        if new and os.path.exists(self.filepath):
+        exists = os.path.exists(self.filepath)
+        if new and exists:
             raise FileExistsError
-        elif new:
+        if not new and not exists:
+            raise FileNotFoundError
+        if new:
             open(self.filepath, "w").close()
 
     @property
git clone https://git.99rst.org/PROJECT