diff --git a/Tools/FileTools.cs b/Tools/FileTools.cs index c42ca84..8fad8bd 100644 --- a/Tools/FileTools.cs +++ b/Tools/FileTools.cs @@ -142,7 +142,10 @@ internal static class FileTools Log($"Searching file: {path}"); if (!File.Exists(path)) - return $"ERROR: File not found: {path}"; + if (Directory.Exists(path)) + return $"ERROR: {path} is a directory, not a file."; + else + return $"ERROR: File not found: {path}"; Regex regex; try @@ -178,7 +181,7 @@ internal static class FileTools } catch (Exception ex) { - return $"ERROR searching '{path}': {ex.Message}"; + return $"ERROR searching '{path}': {ex.Message}\nThis is a bug, tell the user about it."; } } else if (mode == "recursive") @@ -186,7 +189,10 @@ internal static class FileTools Log($"Recursive grep: {pattern} in {path}" + (filePattern != null ? $" (files: {filePattern})" : "")); if (!Directory.Exists(path)) - return $"ERROR: Directory not found: {path}"; + if (File.Exists(path)) + return $"ERROR: {path} is a file, not a directory."; + else + return $"ERROR: Directory not found: {path}"; Regex regex; try @@ -244,7 +250,7 @@ internal static class FileTools } catch (Exception ex) { - return $"ERROR in recursive grep: {ex.Message}"; + return $"ERROR in recursive grep: {ex.Message}.\nThis is a bug, tell the user about it."; } } else