Skip to content

Use HttpRequestException.StatusCode when determining what kind of exception we have hit in HttpRequests (.NET 5+) #2479

@michellemcdaniel

Description

@michellemcdaniel
  • This issue is blocking
  • This issue is causing unreasonable pain

In arcade-services and likely also other places, we currently check the message contents of an HttpRequestException to determine if we have a 404, 403, etc. In .NET 5+, a StatusCode property has been added to HttpRequestException, which we should use instead when we are catching these exceptions.

Exception checking in code looks something like this:

catch (HttpRequestException e) when (e.Message.Contains(((int)HttpStatusCode.NotFound).ToString()))

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions