Skip to content

Revisit HttpRequestException.HttpRequestError type #89080

@stephentoub

Description

@stephentoub

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

Metadata

Metadata

Labels

api-approvedAPI was approved in API review, it can be implementedarea-System.Net.HttpblockingMarks issues that we want to fast track in order to unblock other important work

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions