Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WinHttpException should map to WebException Status #21447

Closed
DalSoft opened this issue May 1, 2017 · 5 comments
Closed

WinHttpException should map to WebException Status #21447

DalSoft opened this issue May 1, 2017 · 5 comments
Labels
area-System.Net.Http enhancement Product code improvement that does NOT require public API changes/additions
Milestone

Comments

@DalSoft
Copy link

DalSoft commented May 1, 2017

At the moment to handle transient exceptions cross platform, I'm having to do something special for .NET Standard Windows only (Map the NativeErrorCode to WebExceptionStatus). But for .NET 4.x and Mono I just get the WebExceptionStatus Status from the InnerException.

Here is how Mono does it for iOS
https://github.com/mono/mono/blob/master/mcs/class/System.Net.Http/HttpClientEx.cs

@davidsh
Copy link
Contributor

davidsh commented May 1, 2017

We have thought about how to improve error handling in HttpClient. HttpWebRequest for example has WebException and WebExceptionStatus enums. This would something for a future release.

HttpClient returns HttpRequestException's. We are thinking about adding a property to that except similar to WebExceptionStatus enum behavior. That is how we would handle cross-platform error codes. We would prefer to make the error handling just rely on a top-level exception property rather than have to use the inner exceptions.

cc: @stephentoub

@davidsh
Copy link
Contributor

davidsh commented May 1, 2017

This is really a dupe of #15567

@davidsh
Copy link
Contributor

davidsh commented Aug 28, 2019

Closing as duplicate of #15567.

@davidsh davidsh closed this as completed Aug 28, 2019
@msftgits msftgits transferred this issue from dotnet/corefx Jan 31, 2020
@msftgits msftgits added this to the 5.0 milestone Jan 31, 2020
@ghost ghost locked as resolved and limited conversation to collaborators Dec 23, 2020
@dotnet dotnet unlocked this conversation Feb 7, 2023
@antonfirsov
Copy link
Member

antonfirsov commented Feb 7, 2023

@DalSoft sorry for pinging you in this old discussion, but I wonder about your experience with .NET 5.0+ era error handling in HttpClient if you can comment on that. Note that HttpClient / SocketsHttpHandler throws specific exceptions for Socket/URI/DNS/SSL errors and #21965 has been addressed in #2281. Is this sufficient, or do have some scenarios we can improve?

@DalSoft
Copy link
Author

DalSoft commented Feb 15, 2023

@DalSoft sorry for pinging you in this old discussion, but I wonder about your experience with .NET 5.0+ era error handling in HttpClient if you can comment on that. Note that HttpClient / SocketsHttpHandler throws specific exceptions for Socket/URI/DNS/SSL errors and #21965 has been addressed in #2281. Is this sufficient, or do have some scenarios we can improve?

The retry code in my RestClient covers all the cases I'm aware off.

https://github.com/DalSoft/DalSoft.RestClient/blob/master/DalSoft.RestClient/Handlers/RetryHandler.cs

@ghost ghost locked as resolved and limited conversation to collaborators Mar 18, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-System.Net.Http enhancement Product code improvement that does NOT require public API changes/additions
Projects
None yet
Development

No branches or pull requests

4 participants