feat: 独立的请求超时异常类型

This commit is contained in:
Fu Diwei
2022-08-08 19:58:58 +08:00
parent 759e68cd9e
commit 1c12754f5b
16 changed files with 239 additions and 7 deletions

View File

@@ -0,0 +1,24 @@
using System;
namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.Exceptions
{
public class WechatTenpayRequestTimeoutException : WechatTenpayException
{
/// <inheritdoc/>
internal WechatTenpayRequestTimeoutException()
{
}
/// <inheritdoc/>
internal WechatTenpayRequestTimeoutException(string message)
: base(message)
{
}
/// <inheritdoc/>
internal WechatTenpayRequestTimeoutException(string message, Exception innerException)
: base(message, innerException)
{
}
}
}

View File

@@ -1,4 +1,4 @@
using System;
using System;
using System.Linq;
using System.Net.Http;
using System.Net.Http.Headers;
@@ -117,6 +117,10 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
using IFlurlResponse flurlResponse = await base.SendRequestAsync(flurlRequest, httpContent, cancellationToken);
return await WrapResponseWithJsonAsync<T>(flurlResponse, cancellationToken);
}
catch (FlurlHttpTimeoutException ex)
{
throw new Exceptions.WechatTenpayRequestTimeoutException(ex.Message, ex);
}
catch (FlurlHttpException ex)
{
throw new WechatTenpayException(ex.Message, ex);
@@ -147,6 +151,10 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
await base.SendRequestWithJsonAsync(flurlRequest, data, cancellationToken);
return await WrapResponseWithJsonAsync<T>(flurlResponse, cancellationToken);
}
catch (FlurlHttpTimeoutException ex)
{
throw new Exceptions.WechatTenpayRequestTimeoutException(ex.Message, ex);
}
catch (FlurlHttpException ex)
{
throw new WechatTenpayException(ex.Message, ex);