2014-05-22 14:35:02 -04:00
|
|
|
class RescueJob < ActiveJob::Base
|
2014-05-22 19:14:13 -04:00
|
|
|
class OtherError < StandardError; end
|
|
|
|
|
|
|
|
rescue_from(ArgumentError) do
|
2014-08-15 17:02:06 -04:00
|
|
|
Thread.current[:ajbuffer] << "rescued from ArgumentError"
|
2014-05-22 14:35:02 -04:00
|
|
|
arguments[0] = "DIFFERENT!"
|
|
|
|
retry_now
|
|
|
|
end
|
|
|
|
|
|
|
|
def perform(person = "david")
|
2014-05-22 19:14:13 -04:00
|
|
|
case person
|
|
|
|
when "david"
|
|
|
|
raise ArgumentError, "Hair too good"
|
|
|
|
when "other"
|
|
|
|
raise OtherError
|
2014-05-22 14:35:02 -04:00
|
|
|
else
|
2014-08-15 17:02:06 -04:00
|
|
|
Thread.current[:ajbuffer] << "performed beautifully"
|
2014-05-22 14:35:02 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|