Moved secure channel hresult to a constant

This commit is contained in:
RogueException
2015-12-29 17:40:49 -04:00
parent c51a049d18
commit ed20d55438
2 changed files with 7 additions and 3 deletions

View File

@@ -13,7 +13,9 @@ using System.Globalization;
namespace Discord.Net.Rest
{
internal sealed class BuiltInEngine : IRestEngine
{
{
private const int HR_SECURECHANNELFAILED = -2146233079;
private readonly DiscordConfig _config;
private readonly HttpClient _client;
private readonly string _baseUrl;
@@ -81,7 +83,7 @@ namespace Discord.Net.Rest
catch (WebException ex)
{
//The request was aborted: Could not create SSL/TLS secure channel.
if (ex.HResult == -2146233079 && retryCount++ < 5)
if (ex.HResult == HR_SECURECHANNELFAILED && retryCount++ < 5)
continue; //Retrying seems to fix this somehow?
throw;
}

View File

@@ -11,6 +11,8 @@ namespace Discord.Net.Rest
{
internal sealed class RestSharpEngine : IRestEngine
{
private const int HR_SECURECHANNELFAILED = -2146233079;
private readonly DiscordConfig _config;
private readonly RestSharp.RestClient _client;
@@ -73,7 +75,7 @@ namespace Discord.Net.Rest
if (statusCode == 0) //Internal Error
{
//The request was aborted: Could not create SSL/TLS secure channel.
if (response.ErrorException.HResult == -2146233079 && retryCount++ < 5)
if (response.ErrorException.HResult == HR_SECURECHANNELFAILED && retryCount++ < 5)
continue; //Retrying seems to fix this somehow?
throw response.ErrorException;
}