Tiny.RestClient v1.6.2 Release Notes
Release Date: 2019-05-04 // almost 5 years ago-
- Now HttpException expose the headers of the response
- Constructor of HttpException is now internal
- ➕ Add possibility to encapsulate HttpException automatically.
We can setup a global handler to provide a logic to encapsulate HttpException automatically. For example I can choose to translate all HttpException with StatusCode NotFound in a NotFoundCustomException.
client.Settings.EncapsulateHttpExceptionHandler = (ex) => { if (ex.StatusCode == System.Net.HttpStatusCode.NotFound) { return new NotFoundCustomException(); } return ex; };
👻 Now if I call an API wich respond with status code NotFound it will throw automaticaly my custom exception.
// Call an API wich throw NotFound error await client.GetRequest("APIWhichNotExists").ExecuteAsync();