Preserve HTTP status codes across target frameworks (#1767)
Copilot-Session: 9a49da98-c8d8-4b90-a6ed-50afe18ac981
This commit is contained in:
parent
f8e9e1d23f
commit
5c305450cd
1 changed files with 53 additions and 10 deletions
|
|
@ -146,14 +146,10 @@ internal sealed partial class AutoDetectingClientSessionTransport : ITransport
|
|||
// keep HttpRequestException as the surfaced type so existing callers can still catch it and read StatusCode.
|
||||
await sseTransport.DisposeAsync().ConfigureAwait(false);
|
||||
LogSseFallbackFailedAfterStreamableHttp(_name, sseError);
|
||||
#if NET
|
||||
throw new HttpRequestException(streamableHttpError.Message, sseError, streamableHttpError.StatusCode);
|
||||
#else
|
||||
// net472 has no HttpRequestException overload that carries a status code, so this target
|
||||
// preserves the status text in the message but not a programmatic StatusCode. Preserving the
|
||||
// status code is intentionally net5+ only rather than an oversight.
|
||||
throw new HttpRequestException(streamableHttpError.Message, sseError);
|
||||
#endif
|
||||
throw HttpRequestExceptionExtensions.Create(
|
||||
streamableHttpError.Message,
|
||||
sseError,
|
||||
streamableHttpError.GetStatusCode());
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue