Class: SolidErrors::Frontend::BacktraceFormatter

Inherits:
Object
  • Object
show all
Defined in:
lib/solid_errors/frontend/backtrace_formatter.rb

Overview

Renders browser frames as Ruby backtrace lines.

Error backends parse backtraces with a Ruby-shaped regex — roughly

/^((?:[a-zA-Z]:)?[^:]+):(\d+)(?::in [`']([^']+)')?$/

so a frame written as "/app/javascript/foo.js:42:in `connect'" is understood, linked to its source and (when the path is under the project root) treated as application code. Two constraints follow from that regex: the file part can't contain a colon, and a trailing ":column" makes the whole line fail to match — hence columns are dropped here and carried in the report context instead.

Frames we can't resolve to a source file are emitted verbatim; backends fall back to showing the unparsed line, so nothing is lost.

Constant Summary collapse

DEFAULT_METHOD =
"<anonymous>"

Instance Method Summary collapse

Constructor Details

#initialize(source_mapper) ⇒ BacktraceFormatter

Returns a new instance of BacktraceFormatter.



21
22
23
# File 'lib/solid_errors/frontend/backtrace_formatter.rb', line 21

def initialize(source_mapper)
  @source_mapper = source_mapper
end

Instance Method Details

#call(frames) ⇒ Array<String>

Parameters:

Returns:

  • (Array<String>)


27
28
29
# File 'lib/solid_errors/frontend/backtrace_formatter.rb', line 27

def call(frames)
  frames.filter_map { |frame| format_frame(frame) }
end