Currently, I have to wrap the code in my derived worker classes that actually does the desired work in rescue blocks
like this:
begin
chart.calculate!
rescue
logger.error "ChartWorker error: #{$!} \n #{$!.backtrace.join("\n")}"
return
end
This makes the ruby code in the workers not pretty like ruby code should be but it is nearly impossible to debug the
workers without these blocks. In my opinion, it is the responsibility of the Worker base class to catch all exceptions
not handled by derived class methods and log them with the date, derived class name, exception and backtrace. It should
probably delete the worker as well because there can be no reasonable expectation that the worker would continue to
do anything useful after it has failed to handle an exception.
|