canton7 / RestEase

Easy-to-use typesafe REST API client library for .NET Standard 1.1 and .NET Framework 4.5 and higher, which is simple and customisable. Inspired by Refit
MIT License
1.08k stars 109 forks source link

Extract ApiException creation from SendRequestAsync method #257

Closed TobiasBreuer closed 1 year ago

TobiasBreuer commented 1 year ago

Discussed in https://github.com/canton7/RestEase/discussions/256

Originally posted by **TobiasBreuer** April 13, 2023 @canton7 : Before creating a PR I would like to get your opinion on that topic. ....

In the end we want to extract the following parts of the Requster SendRequestAsync method to a seperate virtual method that can be customized:

if (!response.IsSuccessStatusCode && !requestInfo.AllowAnyStatusCode)
{
    var deserializer = new ApiExceptionContentDeserializer(this, response, requestInfo);
    throw await ApiException.CreateAsync(message, response, deserializer).ConfigureAwait(false);
}
canton7 commented 1 year ago

That'll be out in 1.6.3 shortly!

TobiasBreuer commented 1 year ago

Awsome! Thanks! However I noticed there is a small spelling mistake in EnsureSuccessulResponseIfNecessary maybe you want to add the missing 'f' in Successul before releasing the new version 😉

canton7 commented 1 year ago

Argh, I went too quickly, thanks. I'll fix that tomorrow.

canton7 commented 1 year ago

Right there we go: 1.6.4 out