Skip to content

Commit

Permalink
error handling in version checker
Browse files Browse the repository at this point in the history
  • Loading branch information
hellzerg committed Jan 5, 2018
1 parent 23e303a commit 96c93fd
Showing 1 changed file with 29 additions and 15 deletions.
44 changes: 29 additions & 15 deletions Optimizer/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,26 +61,37 @@ private void CheckForUpdate()
Encoding = Encoding.UTF8
};

string latestVersion = client.DownloadString(_latestVersionLink);
string latestVersion = string.Empty;
try
{
latestVersion = client.DownloadString(_latestVersionLink);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
}

if (float.Parse(latestVersion) > Program.GetCurrentVersion())
if (!string.IsNullOrEmpty(latestVersion))
{
if (MessageBox.Show(NewVersionMessage(latestVersion), "Update available", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
if (float.Parse(latestVersion) > Program.GetCurrentVersion())
{
try
if (MessageBox.Show(NewVersionMessage(latestVersion), "Update available", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
Process.Start(_releasesLink);
try
{
Process.Start(_releasesLink);
}
catch { }
}
catch { }
}
}
else if (float.Parse(latestVersion) == Program.GetCurrentVersion())
{
MessageBox.Show(_noNewVersionMessage, "No update available", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
{
MessageBox.Show(_betaVersionMessage, "No update available", MessageBoxButtons.OK, MessageBoxIcon.Information);
else if (float.Parse(latestVersion) == Program.GetCurrentVersion())
{
MessageBox.Show(_noNewVersionMessage, "No update available", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
{
MessageBox.Show(_betaVersionMessage, "No update available", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
}

Expand Down Expand Up @@ -1755,7 +1766,10 @@ private void btnChangelog_Click(object sender, EventArgs e)
{
Process.Start(_changelogLink);
}
catch { }
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
}
}

0 comments on commit 96c93fd

Please sign in to comment.