Class: RailsErrorDashboard::Services::BacktraceParser

Inherits:
Object
  • Object
show all
Defined in:
lib/rails_error_dashboard/services/backtrace_parser.rb

Overview

Service: Parse and categorize backtrace frames Filters out framework noise to show only relevant application code

Constant Summary collapse

FRAME_PATTERN =

Match both formats: /path/file.rb:123:in ‘method’ /path/file.rb:123:in ‘ClassName#method’

%r{^(.+):(\d+)(?::in [`'](.+)['`])?$}

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(backtrace_string) ⇒ BacktraceParser

Returns a new instance of BacktraceParser.



17
18
19
# File 'lib/rails_error_dashboard/services/backtrace_parser.rb', line 17

def initialize(backtrace_string)
  @backtrace_string = backtrace_string
end

Class Method Details

.parse(backtrace_string) ⇒ Object



13
14
15
# File 'lib/rails_error_dashboard/services/backtrace_parser.rb', line 13

def self.parse(backtrace_string)
  new(backtrace_string).parse
end

Instance Method Details

#parseObject



21
22
23
24
25
26
27
28
# File 'lib/rails_error_dashboard/services/backtrace_parser.rb', line 21

def parse
  return [] if @backtrace_string.blank?

  lines = @backtrace_string.split("\n")
  lines.map.with_index do |line, index|
    parse_frame(line.strip, index)
  end.compact
end