Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Add StatusCode to HttpRequestException - #32455

#32455
Merged
scalablecory merged 12 commits into
dotnet:masterdotnet/runtime:masterfrom
yaakov-h:httprequestexception-statuscodeyaakov-h/dotnet-runtime:httprequestexception-statuscodeCopy head branch name to clipboard
Feb 24, 2020
Merged

Add StatusCode to HttpRequestException#32455
scalablecory merged 12 commits into
dotnet:masterdotnet/runtime:masterfrom
yaakov-h:httprequestexception-statuscodeyaakov-h/dotnet-runtime:httprequestexception-statuscodeCopy head branch name to clipboard

Conversation

@yaakov-h

@yaakov-h yaakov-h commented Feb 17, 2020

Copy link
Copy Markdown
Member

Implements #911.

TODO:

Code:

  • Add property and constructor, as approved, to Exception object.
  • Add to reference assembly
  • Add tests that it's set when it should be and not when it's not.
  • Add tests that the property is persisted when the exception is serialized.
  • Update callsites to include this when constructing the exception
  • Add tests for callsites to ensure that they do

Docs:

  • Update docs for HttpRequestException to document the new property
  • Update docs for EnsureSuccessStatusCode to point developers at the new property?

The exception doesn't seem to be marked as Serializable in any way, so I'm not sure if/how I should deal with exception serialization.

@Dotnet-GitSync-Bot

Copy link
Copy Markdown
Collaborator

Note regarding the new-api-needs-documentation label:

This serves as a reminder for when your PR is modifying a ref *.cs file and adding/modifying public APIs, to please make sure the API implementation in the src *.cs file is documented with triple slash comments, so the PR reviewers can sign off that change.

@stephentoub

Copy link
Copy Markdown
Member

The exception doesn't seem to be marked as Serializable in any way, so I'm not sure if/how I should deal with exception serialization.

Don't worry about it as part of this PR. If/when someone makes this exception serializable, it'll be up to them to do it in a way that is appropriately compatible with .NET Framework.
cc: @ViktorHofer

Comment thread src/libraries/System.Net.Http/tests/UnitTests/HttpRequestExceptionTests.cs Outdated
@davidsh davidsh added this to the 5.0 milestone Feb 18, 2020
@yaakov-h

Copy link
Copy Markdown
Member Author

ok, I've added some xmldoc comments by pretty much lifting text from similar members elsewhere and tweaking to suit.

@ViktorHofer

Copy link
Copy Markdown
Member

Don't worry about it as part of this PR. If/when someone makes this exception serializable, it'll be up to them to do it in a way that is appropriately compatible with .NET Framework.
cc: @ViktorHofer

The reason why I didn't make that exception serializable is because on .NET Framework it is being serialized with a different mechanism that we don't use on Core: http://index/?query=HttpRequestException (internal link only visible for MSFT employees). We could still make that Exception serializable with the standard mechanism but it wouldn't be exchangeable with .NET Framework.

Comment thread src/libraries/System.Net.Http/src/System/Net/Http/HttpRequestException.cs Outdated

@scalablecory scalablecory left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Are there any other tests that could have StatusCode asserted in? Testing the convenience methods e.g. GetAsync would be good.

Comment thread src/libraries/System.Net.Http/src/System/Net/Http/HttpResponseMessage.cs Outdated
…Message.cs

Co-Authored-By: Cory Nelson <phrosty@gmail.com>
@yaakov-h

Copy link
Copy Markdown
Member Author

@scalablecory Testing the basic convenince methods could be useful. Would I also need to test the convenience methods in System.Net.Http.Formatting (or the upcoming JSON one), or only the base ones defined on HttpClient itself?

@davidsh

davidsh commented Feb 18, 2020

Copy link
Copy Markdown
Contributor

Would I also need to test the convenience methods in System.Net.Http.Formatting (or the upcoming JSON one), or only the base ones defined on HttpClient itself?

The unit tests for this PR should focus only on existing APIs in HttpClient.

@yaakov-h
yaakov-h marked this pull request as ready for review February 19, 2020 07:59
@davidsh

davidsh commented Feb 24, 2020

Copy link
Copy Markdown
Contributor

@yaakov-h Can you clarify if you've addressed all PR feedback? There are still some unresolved comments in the PR. Thanks.

@scalablecory

Copy link
Copy Markdown
Contributor

/azp list

@scalablecory

Copy link
Copy Markdown
Contributor

/azp run runtime-libraries outerloop

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@yaakov-h

Copy link
Copy Markdown
Member Author

@davidsh unless there are any further comments to be had on the xmldoc, I think that's everything.

@scalablecory

Copy link
Copy Markdown
Contributor

It looks good to me, my "accept" check still stands. Thanks for the PR.

@scalablecory
scalablecory merged commit 3a95ea1 into dotnet:master Feb 24, 2020
@yaakov-h
yaakov-h deleted the httprequestexception-statuscode branch February 24, 2020 22:36
alnikola added a commit to dotnet/dotnet-api-docs that referenced this pull request Jun 12, 2020
HttpRequestException.StatusCode property gets the HTTP status code associated with the exception if any.

It was introduced in dotnet/runtime#32455
@ghost ghost locked as resolved and limited conversation to collaborators Dec 10, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.