Skip to content

Instantly share code, notes, and snippets.

@tsommer
Created May 19, 2012 09:56
Show Gist options
  • Save tsommer/2730303 to your computer and use it in GitHub Desktop.
Save tsommer/2730303 to your computer and use it in GitHub Desktop.
Delayed Job exceptions with Airbrake
# Handle errors with Airbrake
Delayed::Worker.class_eval do
def handle_failed_job_with_airbrake(job, error)
handle_failed_job_without_notification job, error
# rescue if Airbrake fails for some reason
begin
Airbrake.notify error
rescue Exception => e
Rails.logger.error "Airbrake failed: #{e.class.name}: #{e.message}"
Rails.logger.flush
end
end
alias_method_chain :handle_failed_job, :airbrake
end
@escray
Copy link

escray commented Oct 26, 2020

what is handle_failed_job_without_notification(job, error) ? just a placeholder ?

@tsommer
Copy link
Author

tsommer commented Oct 26, 2020

what is handle_failed_job_without_notification(job, error) ? just a placeholder ?

great question! I haven't looked at this piece of code for, well, 9 years 👍

I guess that it's a method provided by DelayedJob.
This code hooked into the handle_failed_job chain to loop in Airbrake.

Note however, that the DelayedJob version this was written for is also 9 years old, so the method might not exist anymore

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment