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

Revisit HttpRequestException.HttpRequestError type #89080

Closed
stephentoub opened this issue Jul 18, 2023 · 3 comments · Fixed by #89124
Closed

Revisit HttpRequestException.HttpRequestError type #89080

stephentoub opened this issue Jul 18, 2023 · 3 comments · Fixed by #89124
Assignees
Labels
api-approved API was approved in API review, it can be implemented area-System.Net.Http blocking Marks issues that we want to fast track in order to unblock other important work
Milestone

Comments

@stephentoub
Copy link
Member

stephentoub commented Jul 18, 2023

We just merged a new API adding an HttpRequestError property to HttpRequestException.

public HttpRequestException(string? message, Exception? inner = null, HttpStatusCode? statusCode = null, HttpRequestError? httpRequestError = null);
public HttpRequestError? HttpRequestError { get; }

There is controversy over HttpRequestError, in particular that it's a Nullable<HttpRequestError> when HttpRequestError.Unknown also exists. There are then two different ways to communicate that a meaningful HttpRequestError value could not be provided.

I propose the above be changed to instead be:

public HttpRequestException(HttpRequestError httpRequestError, string? message = null, Exception? inner = null, HttpStatusCode? statusCode = null);
public HttpRequestError HttpRequestError { get; }
  • HttpRequestError parameter to the ctor is moved to be first
  • message is given a nullable default value
  • HttpRequestError property is made non-nullable
@stephentoub stephentoub added area-System.Net.Http blocking Marks issues that we want to fast track in order to unblock other important work api-ready-for-review API is ready for review, it is NOT ready for implementation labels Jul 18, 2023
@stephentoub stephentoub added this to the 8.0.0 milestone Jul 18, 2023
@ghost
Copy link

ghost commented Jul 18, 2023

Tagging subscribers to this area: @dotnet/ncl
See info in area-owners.md if you want to be subscribed.

Issue Details

We just merged a new API adding an HttpRequestError property to HttpRequestException.

        public HttpRequestException(string? message, Exception? inner = null, HttpStatusCode? statusCode = null, HttpRequestError? httpRequestError = null);
        public HttpRequestError? HttpRequestError { get; }

There is controversy over HttpRequestError, in particular that it's a Nullable<HttpRequestError> when HttpRequestError.Unknown also exists. There are then two different ways to communicate that a meaningful HttpRequestError value could not be provided.

I propose the above be changed to instead be:

        public HttpRequestException(HttpRequestError httpRequestError, string? message, Exception? inner = null, HttpStatusCode? statusCode = null);
        public HttpRequestError HttpRequestError { get; }
Author: stephentoub
Assignees: antonfirsov
Labels:

area-System.Net.Http, blocking, api-ready-for-review

Milestone: 8.0.0

@terrajobst
Copy link
Member

This makes sense to me. Let's talk about it later but this seems like an easy change.

@terrajobst
Copy link
Member

terrajobst commented Jul 18, 2023

Video

  • Makes sense as proposed
 namespace System.Net.Http;
 
 public class HttpRequestException : Exception
 {
     // Previously approved
-    public HttpRequestException(string? message, Exception? inner = null, HttpStatusCode? statusCode = null, HttpRequestError? httpRequestError = null);
-    public HttpRequestError? HttpRequestError { get; }

     // Newly approved
+    public HttpRequestException(HttpRequestError httpRequestError, string? message = null, Exception? inner = null, HttpStatusCode? statusCode = null);
+    public HttpRequestError HttpRequestError { get; }
 }

@terrajobst terrajobst added api-approved API was approved in API review, it can be implemented and removed api-ready-for-review API is ready for review, it is NOT ready for implementation labels Jul 18, 2023
@MihaZupan MihaZupan self-assigned this Jul 18, 2023
@ghost ghost added the in-pr There is an active PR which will close this issue when it is merged label Jul 18, 2023
@ghost ghost removed the in-pr There is an active PR which will close this issue when it is merged label Jul 18, 2023
@ghost ghost locked as resolved and limited conversation to collaborators Aug 18, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
api-approved API was approved in API review, it can be implemented area-System.Net.Http blocking Marks issues that we want to fast track in order to unblock other important work
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants