Parent

Methods

Wait::BaseRescuer

Attributes

exceptions[R]
logger[RW]

Public Class Methods

new(exceptions) click to toggle source
# File lib/rescuers/base.rb, line 6
def initialize(exceptions)
  @exceptions = Array(exceptions).flatten
end

Public Instance Methods

indent(lines, spaces = 25) click to toggle source

Indents text a given number of spaces.

# File lib/rescuers/base.rb, line 24
def indent(lines, spaces = 25)
  lines.map { |line| (" " * spaces) + line }.join("\n")
end
log(exception) click to toggle source

Logs an exception.

# File lib/rescuers/base.rb, line 11
def log(exception)
  return if @logger.nil?

  klass = exception.class.name
  # We can omit the message if it's identical to the class name.
  message = exception.message unless exception.message == klass
  # Indent the exception so it stands apart from the rest of the messages.
  backtrace = indent(exception.backtrace)

  @logger.debug("Rescuer") { "rescued: #{klass}#{": #{message}" if message}\n#{backtrace}" }
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.