From 55d5a7a4b86361391b962f7fd038221192a849d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=80=81=E4=B9=9D?= <366193849@qq.com> Date: Tue, 16 Nov 2021 21:25:18 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0HttpConnectTimeoutException?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- FastGithub.Http/HttpClientHandler.cs | 2 +- .../HttpConnectTimeoutException.cs | 21 +++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 FastGithub.Http/HttpConnectTimeoutException.cs diff --git a/FastGithub.Http/HttpClientHandler.cs b/FastGithub.Http/HttpClientHandler.cs index f7d4b3f..5bfedf0 100644 --- a/FastGithub.Http/HttpClientHandler.cs +++ b/FastGithub.Http/HttpClientHandler.cs @@ -108,7 +108,7 @@ namespace FastGithub.Http catch (OperationCanceledException) { cancellationToken.ThrowIfCancellationRequested(); - innerExceptions.Add(new SocketException((int)SocketError.TimedOut)); + innerExceptions.Add(new HttpConnectTimeoutException(ipEndPoint.Address)); } catch (Exception ex) { diff --git a/FastGithub.Http/HttpConnectTimeoutException.cs b/FastGithub.Http/HttpConnectTimeoutException.cs new file mode 100644 index 0000000..8c69528 --- /dev/null +++ b/FastGithub.Http/HttpConnectTimeoutException.cs @@ -0,0 +1,21 @@ +using System; +using System.Net; + +namespace FastGithub.Http +{ + /// + /// http连接超时异常 + /// + sealed class HttpConnectTimeoutException : Exception + { + /// + /// http连接超时异常 + /// + /// 连接的ip + public HttpConnectTimeoutException(IPAddress address) + : base(address.ToString()) + { + + } + } +}