Skip to content

Commit

Permalink
Updater no longer crashes with no internet connection (fixes #4)
Browse files Browse the repository at this point in the history
  • Loading branch information
whampson committed Oct 22, 2022
1 parent 250f65e commit 2e9ebee
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/LCSSaveEditor.GUI/Utils/Updater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ public class Updater
public static async Task<GitHubRelease[]> GetReleaseInfo()
{
using var resp = await GitHubApiGet("https://api.github.com/repos/whampson/lcs-save-editor/releases");
if (resp == null)
{
Log.Error("Unable to get update information. Are you connected to the internet?");
return new GitHubRelease[0];
}
if (resp.StatusCode != HttpStatusCode.OK)
{
return new GitHubRelease[0];
Expand Down Expand Up @@ -143,6 +148,11 @@ private static async Task<HttpWebResponse> GetHttpResponse(HttpWebRequest req)
catch (WebException e)
{
var resp = e.Response as HttpWebResponse;
if (resp == null)
{
Log.Error(e.Message);
return null;
}
if (resp.StatusCode != HttpStatusCode.OK)
{
Log.Error($"HTTP {req.Method} returned {(int) resp.StatusCode} ({resp.StatusDescription}).");
Expand Down

0 comments on commit 2e9ebee

Please sign in to comment.