Ruby HTTP client is not sophisticated enough to handle errors gracefully. I came across a well-designed client for a web service at [AppSignal].
The code for the client is as following:
The code has the following logic:
- Try to establish a connection with the server.
- The request has a timeout and connection refused exceptions.
- If retries fail, code raise the last seen exception.
- Each retry has increased timeout.
Written with StackEdit.