-
-
Notifications
You must be signed in to change notification settings - Fork 396
Open
Description
Flurl/src/Flurl.Http/FlurlResponse.cs
Line 159 in 36a3fa2
| await FlurlClient.HandleExceptionAsync(_call, new FlurlParsingException(_call, "JSON", ex), CancellationToken.None).ConfigureAwait(false); |
I try to parse the response body to throw a meaningful exception from middleware, but when using the GetJsonAsync<T> fails it will incur another OnError being called ultimately causing a stackoverflow crashing your application.
So, are there other means to parse the response body for specific http responses? Should you avoid using the GetJsonAsync in the exception middleware? I now have a workaround by setting and checking the ExceptionHandled flag to break out of recursion but that feels a bit like a hack.
smallest repro:
using var http = new HttpTest();
http.RespondWith("some error", 400);
var act = () => "http://x"
.OnError(async call =>
{
await call.Response.GetJsonAsync<string[]>();
})
.GetJsonAsync();
await act.Should().ThrowAsync<FlurlHttpException>();result:
Stack Overflow Exception
Last runner error: Stack overflow exception occurred in test. Test run is aborted.
rdeveen
Metadata
Metadata
Assignees
Labels
No labels