dotnet / dotnet/dotnet-api-docs

Exception timing

Offen
#992 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
area-System.Net dotnet-api/prod Pri2 untriaged
Vorherrschende Sprache
C#
Sterne
949
Forks
1.7k
Ø Merge
3 T. 27 Min.
Gemergte PRs (30 T.)
49

Beschreibung

It's not clear which exceptions are thrown during the synchronous portion of the call vs. which are applied to the returned task.

For example, ArgumentNullException can be checked for synchronously, so I'd guess that's when it would be thrown; then again, there's nothing stopping the methods from deferring it.

Regarding HttpRequestException, most such exceptions have to be async, but some, such as an immediate check of whether the device is attached to a network, can be done in the sync portion. Does calling code need to be prepared for an HttpRequestException during both the sync and async portions?

---
#### Document Details

⚠ *Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.*

* ID: 2d060a3c-fa61-4f7d-771d-9a33c2bb3dd5
* Version Independent ID: 612cd2e0-d2d5-e0f5-6c1d-5ca962a8813d
* Content: [HttpClient.PostAsync Method (System.Net.Http)](https://docs.microsoft.com/en-us/dotnet/api/system.net.http.httpclient.postasync?view=netframework-4.7.2#System_Net_Http_HttpClient_PostAsync_System_Uri_System_Net_Http_HttpContent_System_Threading_CancellationToken_)
* Content Source: [xml/System.Net.Http/HttpClient.xml](https://github.com/dotnet/dotnet-api-docs/blob/master/xml/System.Net.Http/HttpClient.xml)
* Product: **dotnet-api**
* GitHub Login: @dotnet-bot
* Microsoft Alias: **dotnetcontent**

Beitragsleitfaden

Beitragsleitfaden öffnen

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.