Kong / unirest-java

Unirest in Java: Simplified, lightweight HTTP client library.
http://kong.github.io/unirest-java/
MIT License
2.6k stars 592 forks source link

Add a handler to deal with network connection and timeout failures #313

Closed ryber closed 4 years ago

ryber commented 4 years ago

This adds a more robust error handler class that adds the ability to intercept total network failures like failing to connect. In today's world these errors just throw up out unirest.

It is possible with this to either craft a default response or re-attempt the connection, however keep in mind that Unirest ALREADY attempts to retry a network issue 3 times before throwing an exception so the odds that this handler would be successful with the same request are pretty bad.

This is more likely useful in logging such errors or executing backup plans

ryber commented 4 years ago

Closing this because I'm going to merge the concepts here into a interceptor framework