Ignore invalid or not existing filenames in errors
When there is an exception while accessing a file reported from a linter
we drop the whole match and show a warning.
@@ -955,7 +955,7 @@ class Linter(metaclass=LinterMeta):
return [
error
for error in errors
- if not any(
+ if error is not None and not any(
pattern.search(': '.join([error['error_type'], error['code'], error['msg']]))
for pattern in filters
)
@@ -1079,9 +1079,16 @@ class Linter(metaclass=LinterMeta):
# the working directory
filename = os.path.normpath(os.path.join(self.get_working_dir(self.settings), filename))
- # if this is a match for a different file we need its contents for the below checks
+ try:
+ # if this is a match for a different file we need its contents
+ # for the below checks
if not self.filename or not os.path.samefile(filename, self.filename):
vv = VirtualView.from_file(filename)
+ except (FileNotFoundError, OSError) as err:
+ # warn about the error and drop this match
+ logger.warning('Exception: {}'.format(str(err)))
+ self.notify_failure()
+ return None
else:
# use the filename of the current view
filename = self.view.file_name() or "<untitled {}>".format(self.view.buffer_id())
