handling exception

20 views
Skip to first unread message

alan_b

unread,
Nov 7, 2009, 12:49:36 AM11/7/09
to Typhoeus
i've been using typhoeus for quite a while and sometimes i am bugged
with really strange behavior. after several hours of debugging and i
found it caused by a "raise" statement in my on_complete handler.

i was intended to raise an exception whenever a HTTP status code is
not 200. i discovered that if a exception is raised in the handler,
and you make the same request again immediately, you'll get a nil
(instead of a Typhous::Response).

and if you return a "nil" instead of raising exception in the
on_complete handler, making a call to
Typhoeus::Request.handled_response will give you a Typhous::Response
object instead of a nil.

my suggestion to the code would be in hydra.rb, add a being, rescue,
ensure clause to make sure memoized_requests is cleared up probably?
and enhance the "def handled_response" to enable developer to return
nil from handler?
Reply all
Reply to author
Forward
0 new messages