Module: Rage::Errors

Defined in:
lib/rage/errors.rb

Defined Under Namespace

Classes: AmbiguousRenderError, BadRequest, InvalidCustomProxy, RouterError, UnknownHTTPMethod

Class Method Summary collapse

Class Method Details

.report(exception, context: {}) ⇒ nil

Forward an exception to all registered reporters.

Parameters:

  • exception (Exception)
  • context (Hash) (defaults to: {})

Returns:

  • (nil)


16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/rage/errors.rb', line 16

def report(exception, context: {})
  return if @reporters.empty?
  return if exception.instance_variable_defined?(:@_rage_error_reported)

  ensure_backtrace(exception)

  @reporters.each do |entry|
    __send__(entry.method_name, entry.reporter, exception, context)
  rescue => e
    Rage.logger.error("Error reporter #{entry.reporter.class} failed while reporting #{exception.class}: #{e.class} (#{e.message})")
  end

  exception.instance_variable_set(:@_rage_error_reported, true) unless exception.frozen?

  nil
end