Handle FileNotFoundError

I'm guessing watchdog's behaviour changed in an update, as the error
thrown when the watched directory doesn't exist is now
"FileNotFoundError" instead of "NotADirectoryError". It'll handle either
one now.
This commit is contained in:
Harvey Tindall 2020-07-18 18:15:01 +01:00
parent 95989840f1
commit d5ce6d31c5
1 changed files with 2 additions and 1 deletions

View File

@ -19,7 +19,8 @@ class Watcher:
self.observer.schedule(event_handler, self.dir, recursive=True)
try:
self.observer.start()
except NotADirectoryError:
except (NotADirectoryError,
FileNotFoundError):
log.error(f"Directory {self.dir} does not exist")
try:
while True: