Flurl.Http custom error
Since Flurl sort of specializes in getting from a URL to a deserialized response body in as few keystrokes as possible, it's often asked how to deal with error responses, where the body almost always take a different shape than successful ones. This is why Flurl defaults to throwing on non-2XX responses, so you can deal with error responses like this:
try {
var t = await "http://api.com".GetJsonAsync<T>();
}
catch (FlurlHttpException ex) {
var error = await ex.GetResponseJsonAsync<TError>();
}
There are a few variations:
ex.GetResponseStringAsync();
ex.GetResponseJsonAsync(); // returns a dynamic