Class: RailsErrorDashboard::Services::BacktraceParser
- Inherits:
-
Object
- Object
- RailsErrorDashboard::Services::BacktraceParser
- 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
-
.from_locations(locations) ⇒ Array<Hash>
Convert Thread::Backtrace::Location objects to frame hashes Uses structured data directly — no regex needed.
- .parse(backtrace_string) ⇒ Object
Instance Method Summary collapse
-
#initialize(backtrace_string) ⇒ BacktraceParser
constructor
A new instance of BacktraceParser.
- #parse ⇒ Object
Constructor Details
#initialize(backtrace_string) ⇒ BacktraceParser
Returns a new instance of BacktraceParser.
30 31 32 |
# File 'lib/rails_error_dashboard/services/backtrace_parser.rb', line 30 def initialize(backtrace_string) @backtrace_string = backtrace_string end |
Class Method Details
.from_locations(locations) ⇒ Array<Hash>
Convert Thread::Backtrace::Location objects to frame hashes Uses structured data directly — no regex needed.
21 22 23 24 25 26 27 28 |
# File 'lib/rails_error_dashboard/services/backtrace_parser.rb', line 21 def self.from_locations(locations) return [] if locations.nil? || locations.empty? new(nil).send(:convert_locations, locations) rescue => e RailsErrorDashboard::Logger.debug("[RailsErrorDashboard] BacktraceParser.from_locations failed: #{e.}") [] end |
.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
#parse ⇒ Object
34 35 36 37 38 39 40 41 |
# File 'lib/rails_error_dashboard/services/backtrace_parser.rb', line 34 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 |