http icon indicating copy to clipboard operation
http copied to clipboard

Feature request: timeout subclasses

Open bgentry opened this issue 6 years ago • 3 comments

As of this time, all timeouts raise an HTTP::TimeoutError. I'd like to be able to handle connect timeout errors differently from read or write timeout errors. For example, I want to have a lower connect timeout which I expect to hit occasionally, but also aggressively retry. Because the error happened on connect, I know that no data was sent yet and it's therefore always safe to retry. However, if the error happened on read, I need to take special precautions to see if the server processed the request or not (naturally, the 3rd party API is not idempotent).

I think this could easily be solved, at least for the per operation timeout class. We could have subclasses of HTTP::TimeoutError that describe the specific type of timeout that was encountered.

Is that something you'd accept? I can take a crack at a PR if so.

bgentry avatar May 10 '18 19:05 bgentry

This sounds pretty easy to add in a backward-compatible way so long as they share HTTP::TimeoutError as a parent class

tarcieri avatar May 10 '18 19:05 tarcieri

@tarcieri so if I make a PR, should it target a non-master branch, or would you want to pull that in manually?

bgentry avatar May 10 '18 19:05 bgentry

I'd suggest making a PR against master

tarcieri avatar May 10 '18 19:05 tarcieri