curb icon indicating copy to clipboard operation
curb copied to clipboard

Allow custom exception in on_failure callback

Open aaronchi opened this issue 10 years ago • 5 comments

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?

aaronchi avatar Mar 17 '14 18:03 aaronchi

Same question here, can't figure it out.

scalp42 avatar Nov 19 '14 00:11 scalp42

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?

mccalluc avatar Jan 09 '15 20:01 mccalluc

cc @taf2 maybe?

scalp42 avatar Jan 13 '15 22:01 scalp42

(FWIW: Ended up just checking the status code at the end, and that works for me.)

mccalluc avatar May 29 '15 21:05 mccalluc

+1 Same thing here, i can't add on_failure =(

hensg avatar Jun 01 '16 20:06 hensg

this should be fixed now

taf2 avatar Dec 28 '22 16:12 taf2