Skip to content

Instantly share code, notes, and snippets.

@kjlape
Created June 11, 2019 18:04
Show Gist options
  • Select an option

  • Save kjlape/8919aa98559bf79e3cc4090d24337b21 to your computer and use it in GitHub Desktop.

Select an option

Save kjlape/8919aa98559bf79e3cc4090d24337b21 to your computer and use it in GitHub Desktop.
[WIP][POC] Passively listen to active job errors. This shouldn't disrupt the normal retry_on/discard_on flow. It allows a hook for you to observe errors.
module ActiveJobListeningToErrors
extend ActiveSupport::Concern
module ClassMethods
def on_error(error_class)
around_perform do |job, perform_block|
perform_block.call
rescue error_class => error
yield job, error
raise
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment