Flurl
Flurl copied to clipboard
Serialization based on response status code
A common use case is that you send a request to the API and it comes back with an 400 status and a difference type of JSON then you might have expected with say a 200.
What do you think about adding functionality that would allow us to do something like
.WhenStatus(400)
.ReceiveJson<ValidationResponse>();
If that's part of the same fluent call chain as when you specify a different type for 200 responses, then what's the overall return type of the call? Task<object>? I think it would have to be, because the actual return type can't be known at runtime.
There's already 3 patterns for handing error responses: try/catch, inspecting FlurlResponse, and handling OnError. I'm not sure we need to introduce another way.