lib/job_dispatch/worker/item.rb in job_dispatch-0.1.0 vs lib/job_dispatch/worker/item.rb in job_dispatch-0.2.0

- old
+ new

@@ -28,10 +28,13 @@ Thread.current["JobDispatch::Worker.job_id"] = job_id @klass = target.constantize @result = @klass.__send__(method.to_sym, *params) @status = :success rescue StandardError => ex + + notify_error(ex) rescue nil + @result = { class: ex.class.to_s, message: ex.to_s, backtrace: ex.backtrace, } @@ -39,9 +42,13 @@ JobDispatch.logger.debug ex ensure Thread.current["JobDispatch::Worker.job_id"] = nil JobDispatch.logger.info "Worker completed job #{job_id}: #{target}.#{method}, status: #{@status}" end + end + + def notify_error(exception) + # subclass this to send error notifications end end end end