Skip to content

Make it easy to throw relevant exceptions #203

@dnperfors

Description

@dnperfors

Is your feature request related to a problem? Please describe.
When testing certain Polly policies, it can be useful to throw a connection. However it is not really easy to know what the most common exceptions are that can be thrown by the HttpClientHandler.

Describe the solution you'd like
Add a new ExceptionResponse which can easily throw an HttpRequestException.
As far as I can tell, no other exceptions are thrown by the handler and every exception is wrapped into an HttpRequestException.

Describe alternatives you've considered
As an alternative you can use Responses.Configure(_ => throw new HttpRequestExeption()), however this is more verbose and it would be great to get this in the library itself.

Additional context

  • Documentation of SendAsync shows the exceptions that are generally thrown. TaskCancelledException is already useable via Responses.Timeout()
  • ArgumentNullException and InvalidOperationException are handled by HttpClient itself.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions