diff --git a/src/CLI.cs b/src/CLI.cs
index 0cb9e4b..9f30a46 100644
--- a/src/CLI.cs
+++ b/src/CLI.cs
@@ -49,15 +49,18 @@ public int Run(string[] args)
} catch(InvalidSlnPathException ex) {
Console.Error.WriteLine(ex.Message);
return 2;
- } catch(PathNotFoundException ex) {
+ } catch(SlnFileNotFoundException ex) {
Console.Error.WriteLine(ex.Message);
return 3;
+ } catch(PathNotFoundException ex) {
+ Console.Error.WriteLine(ex.Message);
+ return 4;
} catch(EmptyPathListException) {
Console.Error.WriteLine("No paths supplied to sync with.");
Console.Error.WriteLine("Supply a list of folder/file arguments that you want to be sync'd into the target solution folder.");
Console.Error.WriteLine();
WriteUsage();
- return 4;
+ return 5;
}
Console.Out.WriteLine("Sync completed.");
diff --git a/src/SlnSync.cs b/src/SlnSync.cs
index dfba54f..42dacff 100644
--- a/src/SlnSync.cs
+++ b/src/SlnSync.cs
@@ -20,9 +20,13 @@ public SlnSync() : this(new DefaultGuidGenerator())
/// list of paths to recursively add/update SolutionItems virtual folders with
public void SyncSlnFile(string slnPath, string slnFolder, IEnumerable paths)
{
- if (!File.Exists(slnPath) || !slnPath.EndsWith(".sln"))
+ if (!slnPath.EndsWith(".sln"))
{
- throw new InvalidSlnPathException($"'{slnPath}' is not a sln file");
+ throw new InvalidSlnPathException(slnPath);
+ }
+ if (!File.Exists(slnPath))
+ {
+ throw new SlnFileNotFoundException(slnPath);
}
if (!paths.Any())
{
@@ -121,6 +125,7 @@ private SolutionFolder FindOrCreateSolutionFolder(ICollection solution
=> solutionProjects.OfType().FirstOrDefault(project => project.Name == folderName);
}
-public class PathNotFoundException(string path) : Exception($"Path '{path}' not found");
-public class InvalidSlnPathException(string s) : Exception(s);
+public class PathNotFoundException(string path) : Exception($"Path not found: '{path}'");
+public class SlnFileNotFoundException(string path) : Exception($"Invalid .sln file '{path}' - File not found.");
+public class InvalidSlnPathException(string path) : Exception($"Invalid .sln file '{path}' - File must have .sln extension");
public class EmptyPathListException() : Exception();