Skip to content

Commit

Permalink
Also catch IOExceptions in ApiClient (should fix issue #1)
Browse files Browse the repository at this point in the history
  • Loading branch information
mcebular committed Nov 11, 2020
1 parent 96031a3 commit 3a7f541
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
14 changes: 10 additions & 4 deletions SyncthingStatus/ApiClient.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using SyncthingStatus.Data;
using System;
using System.IO;
using System.Net.Http;
using System.Net.Http.Json;
using System.Threading.Tasks;
Expand Down Expand Up @@ -34,7 +36,8 @@ internal static async Task<PingResponse> Ping()
{
var result = await client.GetFromJsonAsync<PingResponse>("/rest/system/ping");
return result;
} catch(HttpRequestException)
}
catch (Exception ex) when (ex is HttpRequestException || ex is IOException)
{
return null;
}
Expand All @@ -46,7 +49,8 @@ internal static async Task<VersionResponse> Version()
{
var result = await client.GetFromJsonAsync<VersionResponse>("/rest/system/version");
return result;
} catch (HttpRequestException)
}
catch (Exception ex) when (ex is HttpRequestException || ex is IOException)
{
return null;
}
Expand All @@ -59,7 +63,8 @@ internal static async Task<VersionResponse> Version()
var errors = new { Errors = new ErrorResponse.Error[0] };
var result = await client.GetFromJsonAsync<ErrorResponse>("/rest/system/error");
return result.Errors;
} catch(HttpRequestException)
}
catch (Exception ex) when (ex is HttpRequestException || ex is IOException)
{
return null;
}
Expand All @@ -71,7 +76,8 @@ internal static async Task<ConfigResponse> Config()
{
var result = await client.GetFromJsonAsync<ConfigResponse>("/rest/system/config");
return result;
} catch (HttpRequestException)
}
catch (Exception ex) when (ex is HttpRequestException || ex is IOException)
{
return null;
}
Expand Down
2 changes: 1 addition & 1 deletion SyncthingStatus/SyncthingStatus.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<TargetFramework>netcoreapp3.1</TargetFramework>
<UseWindowsForms>true</UseWindowsForms>
<ApplicationIcon>Resources\think.ico</ApplicationIcon>
<Version>0.3</Version>
<Version>0.4</Version>
<PackageProjectUrl></PackageProjectUrl>
</PropertyGroup>

Expand Down

0 comments on commit 3a7f541

Please sign in to comment.