Created
June 11, 2019 18:04
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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