Skip to content

Commit eee6bba

Browse files
committed
Use HttpRequestError.Unknown for the rest
1 parent 2bee08f commit eee6bba

File tree

4 files changed

+10
-6
lines changed

4 files changed

+10
-6
lines changed

src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/Http2Connection.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2205,7 +2205,7 @@ internal void Trace(int streamId, string message, [CallerMemberName] string? mem
22052205

22062206
[DoesNotReturn]
22072207
private static void ThrowRetry(string message, Exception? innerException = null) =>
2208-
throw new HttpRequestException(message, innerException, allowRetry: RequestRetryType.RetryOnConnectionFailure);
2208+
throw new HttpRequestException(HttpRequestError.Unknown, message, innerException, RequestRetryType.RetryOnConnectionFailure);
22092209

22102210
private static Exception GetRequestAbortedException(Exception? innerException = null) =>
22112211
innerException as HttpIOException ?? new IOException(SR.net_http_request_aborted, innerException);

src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/Http3Connection.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ public async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, lon
208208

209209
if (quicStream == null)
210210
{
211-
throw new HttpRequestException(SR.net_http_request_aborted, null, RequestRetryType.RetryOnConnectionFailure);
211+
throw new HttpRequestException(HttpRequestError.Unknown, SR.net_http_request_aborted, null, RequestRetryType.RetryOnConnectionFailure);
212212
}
213213

214214
requestStream!.StreamId = quicStream.Id;
@@ -221,7 +221,7 @@ public async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, lon
221221

222222
if (goAway)
223223
{
224-
throw new HttpRequestException(SR.net_http_request_aborted, null, RequestRetryType.RetryOnConnectionFailure);
224+
throw new HttpRequestException(HttpRequestError.Unknown, SR.net_http_request_aborted, null, RequestRetryType.RetryOnConnectionFailure);
225225
}
226226

227227
if (NetEventSource.Log.IsEnabled()) Trace($"Sending request: {request}");
@@ -237,7 +237,7 @@ public async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, lon
237237
{
238238
// This will happen if we aborted _connection somewhere and we have pending OpenOutboundStreamAsync call.
239239
// note that _abortException may be null if we closed the connection in response to a GOAWAY frame
240-
throw new HttpRequestException(SR.net_http_client_execution_error, _abortException, RequestRetryType.RetryOnConnectionFailure);
240+
throw new HttpRequestException(HttpRequestError.Unknown, SR.net_http_client_execution_error, _abortException, RequestRetryType.RetryOnConnectionFailure);
241241
}
242242
finally
243243
{

src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/Http3RequestStream.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ await Task.WhenAny(sendContentTask, readResponseTask).ConfigureAwait(false) == s
252252
{
253253
case Http3ErrorCode.VersionFallback:
254254
// The server is requesting us fall back to an older HTTP version.
255-
throw new HttpRequestException(SR.net_http_retry_on_older_version, ex, RequestRetryType.RetryOnLowerHttpVersion);
255+
throw new HttpRequestException(HttpRequestError.Unknown, SR.net_http_retry_on_older_version, ex, RequestRetryType.RetryOnLowerHttpVersion);
256256

257257
case Http3ErrorCode.RequestRejected:
258258
// The server is rejecting the request without processing it, retry it on a different connection.

src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpConnection.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -882,19 +882,23 @@ private bool MapSendException(Exception exception, CancellationToken cancellatio
882882
mappedException = CancellationHelper.CreateOperationCanceledException(exception, cancellationToken);
883883
return true;
884884
}
885+
885886
if (exception is InvalidOperationException)
886887
{
887888
// For consistency with other handlers we wrap the exception in an HttpRequestException.
888889
mappedException = new HttpRequestException(SR.net_http_client_execution_error, exception);
889890
return true;
890891
}
892+
891893
if (exception is IOException ioe)
892894
{
893895
// For consistency with other handlers we wrap the exception in an HttpRequestException.
894896
// If the request is retryable, indicate that on the exception.
895-
mappedException = new HttpRequestException(SR.net_http_client_execution_error, ioe, _canRetry ? RequestRetryType.RetryOnConnectionFailure : RequestRetryType.NoRetry);
897+
HttpRequestError error = ioe is HttpIOException httpIoe ? httpIoe.HttpRequestError : HttpRequestError.Unknown;
898+
mappedException = new HttpRequestException(error, SR.net_http_client_execution_error, ioe, _canRetry ? RequestRetryType.RetryOnConnectionFailure : RequestRetryType.NoRetry);
896899
return true;
897900
}
901+
898902
// Otherwise, just allow the original exception to propagate.
899903
mappedException = exception;
900904
return false;

0 commit comments

Comments
 (0)