mirror of
https://github.com/velopack/velopack.git
synced 2025-10-25 15:19:22 +00:00
Refactor VelopackApp exceptions
This commit is contained in:
@@ -80,20 +80,19 @@ namespace Velopack.Packaging
|
||||
psi.AppendArgumentListSafe(new[] { "--veloapp-version" }, out var _);
|
||||
var output = psi.Output(5000);
|
||||
if (String.IsNullOrWhiteSpace(output)) {
|
||||
throw new UserErrorException(
|
||||
"Failed to verify VelopackApp (Exited with no output). " +
|
||||
"Ensure you have add the startup code to your Program.Main(): VelopackApp.Build().Run(); and then re-compile your application.");
|
||||
throw new VelopackAppVerificationException("Exited with no output");
|
||||
}
|
||||
var version = SemanticVersion.Parse(output.Trim());
|
||||
if (version != VelopackRuntimeInfo.VelopackNugetVersion) {
|
||||
Log.Warn($"VelopackApp version '{version}' does not match CLI version '{VelopackRuntimeInfo.VelopackNugetVersion}'.");
|
||||
if (SemanticVersion.TryParse(output.Trim(), out var version)) {
|
||||
if (version != VelopackRuntimeInfo.VelopackNugetVersion) {
|
||||
Log.Warn($"VelopackApp version '{version}' does not match CLI version '{VelopackRuntimeInfo.VelopackNugetVersion}'.");
|
||||
} else {
|
||||
Log.Info($"VelopackApp version verified ({version}).");
|
||||
}
|
||||
} else {
|
||||
Log.Info($"VelopackApp version verified ({version}).");
|
||||
throw new VelopackAppVerificationException($"Failed to parse version: {output.Trim()}");
|
||||
}
|
||||
} catch (TimeoutException) {
|
||||
throw new UserErrorException(
|
||||
"Failed to verify VelopackApp (Timed out). " +
|
||||
"Ensure you have add the startup code to your Program.Main(): VelopackApp.Build().Run(); and then re-compile your application.");
|
||||
throw new VelopackAppVerificationException("Timed out");
|
||||
}
|
||||
|
||||
var suffix = ReleaseEntryHelper.GetPkgSuffix(SupportedTargetOs, channel);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Text;
|
||||
@@ -10,6 +11,7 @@ namespace Velopack.Packaging
|
||||
/// <summary>
|
||||
/// Denotes that an error has occurred for which a stack trace should not be printed.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class UserErrorException : Exception
|
||||
{
|
||||
public UserErrorException()
|
||||
|
||||
21
src/Velopack.Packaging/VelopackAppVerificationException.cs
Normal file
21
src/Velopack.Packaging/VelopackAppVerificationException.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Velopack.Packaging
|
||||
{
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class VelopackAppVerificationException : UserErrorException
|
||||
{
|
||||
public VelopackAppVerificationException(string message)
|
||||
: base(
|
||||
$"Failed to verify VelopackApp ({message}). " +
|
||||
$"Ensure you have added the startup code to the beginning of your Program.Main(): VelopackApp.Build().Run(); " +
|
||||
$"and then re-compile/re-publish your application.")
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user