curb
curb copied to clipboard
Allow custom exception in on_failure callback
I'm trying to use on_failure to raise a custom error and then rescue it elsewhere in my app, but curb/multi doesn't seem to allow this and returns 'uncaught exception from callback'.
Is this just not possible to do when using multi?
Same question here, can't figure it out.
Ditto. For example:
2.0.0-p353 :002 > require 'curb'
=> true
2.0.0-p353 :003 > c = Curl::Easy.new('http://example.org/404')
=> #<Curl::Easy http://example.org/404>
2.0.0-p353 :004 > c.verbose = true
=> true
2.0.0-p353 :005 > c.on_missing {|x| raise 'Does this work?'}
=> nil
2.0.0-p353 :006 > c.perform
...
> GET /404 HTTP/1.1
...
< HTTP/1.1 404 Not Found
...
.../.rvm/gems/ruby-2.0.0-p353/gems/curb-0.8.6/lib/curl/easy.rb:68: warning: uncaught exception from callback
=> true
This is frustrating. I would like to exit quickly if any of my API calls fail, and handle it in a rescue
clause, but that doesn't seem to be possible. Are we just not using the library the right way?
cc @taf2 maybe?
(FWIW: Ended up just checking the status code at the end, and that works for me.)
+1 Same thing here, i can't add on_failure =(
this should be fixed now