module Eventboss::SafeThread

SafeThread includes thread handling with automatic error reporting

Public Instance Methods

handle_exception(exception, context) click to toggle source
# File lib/eventboss/safe_thread.rb, line 16
def handle_exception(exception, context)
  context.freeze
  Eventboss.configuration.error_handlers.each do |handler|
    handler.call(exception, context)
  end
end
safe_thread(name) { || ... } click to toggle source
# File lib/eventboss/safe_thread.rb, line 4
def safe_thread(name)
  Thread.new do
    begin
      Thread.current[:ah_eventboss_label] = name
      yield
    rescue Exception => exception
      handle_exception(exception, name: name)
      raise exception
    end
  end
end