Sha256: 42d7beb34f53c1f756c9790f90432d3af331fbfbf8ad0d5fcae1fd668f059e28

Contents?: true

Size: 686 Bytes

Versions: 2

Compression:

Stored size: 686 Bytes

Contents

require_relative '../support/job_buffer'

class RescueJob < ActiveJob::Base
  class OtherError < StandardError; end

  rescue_from(ArgumentError) do
    JobBuffer.add('rescued from ArgumentError')
    arguments[0] = "DIFFERENT!"
    retry_job
  end

  rescue_from(ActiveJob::DeserializationError) do |e|
    JobBuffer.add('rescued from DeserializationError')
    JobBuffer.add("DeserializationError original exception was #{e.original_exception.class.name}")
  end

  def perform(person = "david")
    case person
    when "david"
      raise ArgumentError, "Hair too good"
    when "other"
      raise OtherError
    else
      JobBuffer.add('performed beautifully')
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
activejob-lock-0.0.2 rails/activejob/test/jobs/rescue_job.rb
activejob-lock-0.0.1 rails/activejob/test/jobs/rescue_job.rb