mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-22 04:34:59 +00:00
enhance: show inner exception message if possible when check update failed
Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
parent
760e44877b
commit
822452a20c
3 changed files with 43 additions and 24 deletions
56
src/Models/SelfUpdate.cs
Normal file
56
src/Models/SelfUpdate.cs
Normal file
|
@ -0,0 +1,56 @@
|
|||
using System;
|
||||
using System.Reflection;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace SourceGit.Models
|
||||
{
|
||||
public class Version
|
||||
{
|
||||
[JsonPropertyName("name")]
|
||||
public string Name { get; set; }
|
||||
|
||||
[JsonPropertyName("tag_name")]
|
||||
public string TagName { get; set; }
|
||||
|
||||
[JsonPropertyName("body")]
|
||||
public string Body { get; set; }
|
||||
|
||||
public bool IsNewVersion
|
||||
{
|
||||
get
|
||||
{
|
||||
try
|
||||
{
|
||||
System.Version version = new System.Version(TagName.Substring(1));
|
||||
System.Version current = Assembly.GetExecutingAssembly().GetName().Version!;
|
||||
return current.CompareTo(version) < 0;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class AlreadyUpToDate
|
||||
{
|
||||
}
|
||||
|
||||
public class SelfUpdateFailed
|
||||
{
|
||||
public string Reason
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
public SelfUpdateFailed(Exception e)
|
||||
{
|
||||
if (e.InnerException is { } inner)
|
||||
Reason = inner.Message;
|
||||
else
|
||||
Reason = e.Message;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue