Skip to content

Commit

Permalink
Merge pull request #34 from juwens/bugfix/client_crash_without_internet
Browse files Browse the repository at this point in the history
fix client crash when started without internet connection
  • Loading branch information
fernandreu committed Mar 29, 2019
2 parents a8fca56 + 94ee0c6 commit 979ff81
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions OfficeRibbonXEditor/Services/VersionChecker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,19 @@ public class VersionChecker : IVersionChecker
public async Task<string> CheckVersionAsync(CancellationToken cancelToken = default(CancellationToken))
{
string latest;
using (var httpClient = new HttpClient())
try
{
using (var httpClient = new HttpClient())
{
var uri = new Uri(CheckUrl);
var response = await httpClient.GetAsync(uri, cancelToken);
latest = await response.Content.ReadAsStringAsync();
}
}
catch (Exception e)
{
var uri = new Uri(CheckUrl);
var response = await httpClient.GetAsync(uri, cancelToken);
latest = await response.Content.ReadAsStringAsync();
Debug.Fail(e.Message);
return null;
}

if (!Regex.IsMatch(latest, @"^\d+\.\d+\.\d+\.\d+$"))
Expand Down

0 comments on commit 979ff81

Please sign in to comment.