Skip to content
This repository was archived by the owner on Apr 14, 2022. It is now read-only.

Catch/ignore/handle exceptions from FileSystemGlobbing #463

Closed
jakebailey opened this issue Dec 6, 2018 · 2 comments
Closed

Catch/ignore/handle exceptions from FileSystemGlobbing #463

jakebailey opened this issue Dec 6, 2018 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@jakebailey
Copy link
Member

There seem to be quite a few of exceptions coming out of FileSystemGlobbing, which is only used inside of LoadDirectoryFiles. Most frequent is an UnauthorizedAccessException:

 at System.IO.Enumeration.FileSystemEnumerator`1.CreateDirectoryHandle(String path, Boolean ignoreNotFound)
 at System.IO.Enumeration.FileSystemEnumerator`1..ctor(String directory, EnumerationOptions options)
 at System.IO.Enumeration.FileSystemEnumerable`1..ctor(String directory, FindTransform transform, EnumerationOptions options)
 at System.IO.Enumeration.FileSystemEnumerableFactory.FileSystemInfos(String directory, String expression, EnumerationOptions options)
 at System.IO.DirectoryInfo.InternalEnumerateInfos(String path, String searchPattern, SearchTarget searchTarget, EnumerationOptions options)
 at Microsoft.Extensions.FileSystemGlobbing.Abstractions.DirectoryInfoWrapper.EnumerateFileSystemInfos()+MoveNext()
 at System.Collections.Generic.List`1.AddEnumerable(IEnumerable`1 enumerable)
 at System.Collections.Generic.List`1.InsertRange(Int32 index, IEnumerable`1 collection)
 at Microsoft.Extensions.FileSystemGlobbing.Internal.MatcherContext.Match(DirectoryInfoBase directory, S

But we also see DirectoryNotFoundException, IOException, PathTooLongException, and FileNotFoundException.

Right now, these exceptions during workspace/didChangeConfiguration go unhandled, produce an error message for the user via RPC, and record the exception.

Looking at the call site:

if (!_filesLoaded) {
    await LoadDirectoryFiles();
}
_filesLoaded = true;

It may be better idea to do something on the order of:

if (!_filesLoaded) {
    try {
        await LoadDirectoryFiles();
        _filesLoaded = true;
    } catch (Exception ex) when (!ex.IsCriticalException()) {
        // Log something to the user
    }
}

That way, we don't record events that are really just errors in the user's configuration and also give feedback as to what's wrong.

@MikhailArkhipov
Copy link

DirectoryNotFoundException is IOException as is FileNotFoundException. Basically IO produces IOException, UnauthorizedAccessException and ArgumentException.

@jakebailey
Copy link
Member Author

Fixed in #498.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants