Class: Hatchet::Message::ErrorDecorator

Inherits:
SimpleDelegator
  • Object
show all
Defined in:
lib/hatchet/message.rb

Instance Method Summary collapse

Constructor Details

#initialize(error, backtrace_filters) ⇒ ErrorDecorator

Returns a new instance of ErrorDecorator.



21
22
23
24
25
# File 'lib/hatchet/message.rb', line 21

def initialize(error, backtrace_filters)
  super(error)
  @error = error
  @backtrace_filters = backtrace_filters
end

Instance Method Details

#__filtered_line(line) ⇒ Object



31
32
33
34
35
36
37
38
39
# File 'lib/hatchet/message.rb', line 31

def __filtered_line(line)
  @backtrace_filters.each do |prefixes, replacement|
    Array[*prefixes].each do |prefix|
      return replacement + line[prefix.length..-1] if line.start_with?(prefix)
    end
  end

  line
end

#backtraceObject



27
28
29
# File 'lib/hatchet/message.rb', line 27

def backtrace
  @backtrace ||= @error.backtrace.map { |line| __filtered_line(line) }
end

#classObject



41
42
43
# File 'lib/hatchet/message.rb', line 41

def class
  __getobj__.class
end