module Tengine::Core::EventExceptionReportable

Constants

EVENT_EXCEPTION_REPORTERS
FIRE_ALL
FIRE_EXCEPT_TESTING_ERROR
RAISE_ALL

Public Class Methods

to_reporter(reporter) click to toggle source
# File lib/tengine/core/event_exception_reportable.rb, line 36
def to_reporter(reporter)
  if reporter.is_a?(Symbol)
    result = EVENT_EXCEPTION_REPORTERS[reporter]
    raise NameError, "Unknown reporter: #{reporter.inspect}" unless result
    result
  elsif reporter.respond_to?(:call)
    reporter
  else
    raise ArgumentError, "Invalid reporter: #{reporter.inspect}"
  end
end

Public Instance Methods

report_on_exception(dsl_context, event) { || ... } click to toggle source
# File lib/tengine/core/event_exception_reportable.rb, line 74
def report_on_exception(dsl_context, event)
  begin
    yield
  rescue Exception => e
    Tengine.logger.error("[#{e.class.name}] #{e.message}\n  " << e.backtrace.join("\n  "))
    if reporter = Tengine::Core::Kernel.event_exception_reporter
      reporter.call(self, dsl_context, event, e)
    end
  end
end