From 107ca20c5bd05adb73b7c7a1a4ef43e3d429ca51 Mon Sep 17 00:00:00 2001 From: Tyler Leonhardt Date: Mon, 22 Jan 2018 13:13:18 -0800 Subject: [PATCH 1/2] change Enumerate* to Get* --- src/PowerShellEditorServices/Workspace/Workspace.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/PowerShellEditorServices/Workspace/Workspace.cs b/src/PowerShellEditorServices/Workspace/Workspace.cs index 8cf038e59..5a67c504e 100644 --- a/src/PowerShellEditorServices/Workspace/Workspace.cs +++ b/src/PowerShellEditorServices/Workspace/Workspace.cs @@ -241,7 +241,7 @@ private IEnumerable RecursivelyEnumerateFiles(string folderPath) try { - IEnumerable subDirs = Directory.EnumerateDirectories(folderPath); + IEnumerable subDirs = Directory.GetDirectories(folderPath); foreach (string dir in subDirs) { foundFiles = @@ -274,7 +274,7 @@ private IEnumerable RecursivelyEnumerateFiles(string folderPath) { foundFiles = foundFiles.Concat( - Directory.EnumerateFiles( + Directory.GetFiles( folderPath, pattern)); } From 09cbdaaef222c6a8e1fefff4b770ac3baa64d50e Mon Sep 17 00:00:00 2001 From: Tyler Leonhardt Date: Mon, 22 Jan 2018 14:02:25 -0800 Subject: [PATCH 2/2] catch all the exceptions --- .../Workspace/Workspace.cs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/PowerShellEditorServices/Workspace/Workspace.cs b/src/PowerShellEditorServices/Workspace/Workspace.cs index 5a67c504e..3b5749f5e 100644 --- a/src/PowerShellEditorServices/Workspace/Workspace.cs +++ b/src/PowerShellEditorServices/Workspace/Workspace.cs @@ -278,10 +278,22 @@ private IEnumerable RecursivelyEnumerateFiles(string folderPath) folderPath, pattern)); } - catch (UnauthorizedAccessException e) + catch (DirectoryNotFoundException e) { this.logger.WriteException( - $"Could not enumerate files in the path '{folderPath}' due to a file not being accessible", + $"Could not enumerate files in the path '{folderPath}' due to a path being an invalid path", + e); + } + catch (PathTooLongException e) + { + this.logger.WriteException( + $"Could not enumerate files in the path '{folderPath}' due to a path being too long", + e); + } + catch (Exception e) when (e is SecurityException || e is UnauthorizedAccessException) + { + this.logger.WriteException( + $"Could not enumerate files in the path '{folderPath}' due to a path not being accessible", e); } }