From 10c7084cdf6b19b1e87d959d2d6f2997ef963824 Mon Sep 17 00:00:00 2001 From: Robert Holt Date: Wed, 23 Jan 2019 09:43:33 -0800 Subject: [PATCH 1/3] Handle arbitrary exceptions when recursing workspace --- src/PowerShellEditorServices/Workspace/Workspace.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/PowerShellEditorServices/Workspace/Workspace.cs b/src/PowerShellEditorServices/Workspace/Workspace.cs index 6b31b094f..9217fb8a7 100644 --- a/src/PowerShellEditorServices/Workspace/Workspace.cs +++ b/src/PowerShellEditorServices/Workspace/Workspace.cs @@ -345,6 +345,12 @@ private void RecursivelyEnumerateFiles(string folderPath, ref List found continue; } + catch (Exception e) + { + this.logger.WriteHandledException( + $"Could not enumerate files in the path '{folderPath}' due to an exception", + e); + } foundFiles.AddRange(psFiles); } @@ -386,6 +392,13 @@ private void RecursivelyEnumerateFiles(string folderPath, ref List found return; } + catch (Exception e) + { + this.logger.WriteHandledException( + $"Could not enumerate directories in the path '{folderPath}' due to an exception", + e); + } + foreach (string subDir in subDirs) { From 46ff0953da0ab1c77988b2d0d3e53b6f6aa51b72 Mon Sep 17 00:00:00 2001 From: Robert Holt Date: Wed, 23 Jan 2019 10:00:34 -0800 Subject: [PATCH 2/3] Jump out of golden path on exceptions --- src/PowerShellEditorServices/Workspace/Workspace.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/PowerShellEditorServices/Workspace/Workspace.cs b/src/PowerShellEditorServices/Workspace/Workspace.cs index 9217fb8a7..a32ed399d 100644 --- a/src/PowerShellEditorServices/Workspace/Workspace.cs +++ b/src/PowerShellEditorServices/Workspace/Workspace.cs @@ -350,6 +350,7 @@ private void RecursivelyEnumerateFiles(string folderPath, ref List found this.logger.WriteHandledException( $"Could not enumerate files in the path '{folderPath}' due to an exception", e); + continue; } foundFiles.AddRange(psFiles); @@ -397,6 +398,7 @@ private void RecursivelyEnumerateFiles(string folderPath, ref List found this.logger.WriteHandledException( $"Could not enumerate directories in the path '{folderPath}' due to an exception", e); + return; } From fdd0d738a749a5588e67eb6770711ebdd9f5b3e5 Mon Sep 17 00:00:00 2001 From: Robert Holt Date: Wed, 23 Jan 2019 10:05:18 -0800 Subject: [PATCH 3/3] Blank lines --- src/PowerShellEditorServices/Workspace/Workspace.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/PowerShellEditorServices/Workspace/Workspace.cs b/src/PowerShellEditorServices/Workspace/Workspace.cs index a32ed399d..6f9cb8beb 100644 --- a/src/PowerShellEditorServices/Workspace/Workspace.cs +++ b/src/PowerShellEditorServices/Workspace/Workspace.cs @@ -350,6 +350,7 @@ private void RecursivelyEnumerateFiles(string folderPath, ref List found this.logger.WriteHandledException( $"Could not enumerate files in the path '{folderPath}' due to an exception", e); + continue; } @@ -398,6 +399,7 @@ private void RecursivelyEnumerateFiles(string folderPath, ref List found this.logger.WriteHandledException( $"Could not enumerate directories in the path '{folderPath}' due to an exception", e); + return; }