Closed confact closed 2 years ago
@confact thanks, this has been in my mind, but I didn't have an issue for it yet.
@confact I think this is already possible with the current RC, which includes before/after hooks. Here's a minimal example:
class ErrorHandlerJob < Mosquito::QueuedJob
def perform
raise "Error!"
end
after do
return unless failed?
Log.error(exception: exception) { "Job failed after hook" }
# Honeybadger.dispatch exception
end
end
This pattern could be monkey-patched into Mosquito::Job to be applied application wide, or packed up as a module to be selectively included in jobs which need it.
Notably this would miss exceptions which are thrown in an after-hook. That would actually crash the runner itself, and it would require an additional catch written around the runner initiation. Let me know if that doesn't cast a wide enough net. I'm going to mark this as done, and go write a page for the website about it.
To be able to send exceptions and errors to Sentry, rollbar, bugsnag, errordeck, and so on.
It would help to figure out easier what is going on in the jobs.