diff --git a/src/PowerShellEditorServices/Workspace/Workspace.cs b/src/PowerShellEditorServices/Workspace/Workspace.cs index f5deee6c8..8cf038e59 100644 --- a/src/PowerShellEditorServices/Workspace/Workspace.cs +++ b/src/PowerShellEditorServices/Workspace/Workspace.cs @@ -8,8 +8,8 @@ using System.Collections.Generic; using System.Linq; using System.IO; +using System.Security; using System.Text; -using System.Diagnostics; namespace Microsoft.PowerShell.EditorServices { @@ -249,7 +249,19 @@ private IEnumerable RecursivelyEnumerateFiles(string folderPath) RecursivelyEnumerateFiles(dir)); } } - catch (UnauthorizedAccessException e) + catch (DirectoryNotFoundException e) + { + this.logger.WriteException( + $"Could not enumerate files in the path '{folderPath}' due to it being an invalid path", + e); + } + catch (PathTooLongException e) + { + this.logger.WriteException( + $"Could not enumerate files in the path '{folderPath}' due to the 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 the path not being accessible",