diff --git a/src/Squirrel/ExceptionTypes.cs b/src/Squirrel/ExceptionTypes.cs new file mode 100644 index 000000000..2cd86bdb7 --- /dev/null +++ b/src/Squirrel/ExceptionTypes.cs @@ -0,0 +1,50 @@ +using System; + +namespace Squirrel +{ + /// + /// + /// Base class for Squirrel-originated exceptions. + /// + public abstract class SquirrelBaseException: Exception + { + protected SquirrelBaseException(string message) + : base(message) + { + } + } + + /// + /// Thrown when no Releases folder or RELEASES file is found at the specified location. + /// + public class SquirrelReleasesMissingException : SquirrelBaseException + { + public SquirrelReleasesMissingException(string message) + : base(message) + { + } + } + + /// + /// Thrown when the Releases\RELEASES file is empty or corrupt. + /// + public class SquirrelReleasesCorruptException: SquirrelBaseException + { + public SquirrelReleasesCorruptException(string message) + : base(message) + { + } + } + + /// + /// Thrown when Update.exe isn't found in the expected location. + /// + /// See https://github.com/Squirrel/Squirrel.Windows/blob/master/docs/using/debugging-updates.md for more information. + public class SquirrelNoUpdateException: SquirrelBaseException + { + public SquirrelNoUpdateException(string message) + : base(message) + { + } + } +} diff --git a/src/Squirrel/Squirrel.csproj b/src/Squirrel/Squirrel.csproj index 9769199ef..4fea080ad 100644 --- a/src/Squirrel/Squirrel.csproj +++ b/src/Squirrel/Squirrel.csproj @@ -84,6 +84,7 @@ + diff --git a/src/Squirrel/UpdateManager.CheckForUpdates.cs b/src/Squirrel/UpdateManager.CheckForUpdates.cs index 9ba91a736..5530d132f 100644 --- a/src/Squirrel/UpdateManager.CheckForUpdates.cs +++ b/src/Squirrel/UpdateManager.CheckForUpdates.cs @@ -97,7 +97,7 @@ public async Task CheckForUpdate( "The directory {0} does not exist, something is probably broken with your application", updateUrlOrPath); - throw new Exception(message); + throw new SquirrelReleasesMissingException(message); } var fi = new FileInfo(Path.Combine(updateUrlOrPath, "RELEASES")); @@ -110,7 +110,7 @@ public async Task CheckForUpdate( var packages = (new DirectoryInfo(updateUrlOrPath)).GetFiles("*.nupkg"); if (packages.Length == 0) { - throw new Exception(message); + throw new SquirrelReleasesMissingException(message); } // NB: Create a new RELEASES file since we've got a directory of packages @@ -127,7 +127,7 @@ public async Task CheckForUpdate( progress(66); if (!remoteReleases.Any()) { - throw new Exception("Remote release File is empty or corrupted"); + throw new SquirrelReleasesCorruptException("Remote release File is empty or corrupted"); } ret = determineUpdateInfo(intention, localReleases, remoteReleases, ignoreDeltaUpdates); @@ -154,7 +154,7 @@ UpdateInfo determineUpdateInfo(UpdaterIntention intention, IEnumerable