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-17 09:23:24 -04:00
|
|
|
JobBuffer.add('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-17 09:23:24 -04:00
|
|
|
JobBuffer.add('performed beautifully')
|
2014-05-22 14:35:02 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|