Skip to content

Make it easy to throw relevant exceptions #203

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

Open
dnperfors opened this issue Dec 8, 2022 · 0 comments
Open

Make it easy to throw relevant exceptions #203

dnperfors opened this issue Dec 8, 2022 · 0 comments
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed

Comments

@dnperfors
Copy link
Member

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.
@dnperfors dnperfors added the enhancement New feature or request label Dec 8, 2022
@dnperfors dnperfors added this to the Version 0.11 milestone Dec 8, 2022
@dnperfors dnperfors added help wanted Extra attention is needed good first issue Good for newcomers labels Dec 8, 2022
@dnperfors dnperfors modified the milestones: Version 0.11, Version 0.12 Jun 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant