Skip to content

Commit

Permalink
Fix handling of backtrace lines that don't have a file path
Browse files Browse the repository at this point in the history
  • Loading branch information
fractaledmind committed Jan 29, 2024
1 parent 3036b27 commit 638001e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
9 changes: 5 additions & 4 deletions app/models/solid_errors/backtrace_line.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class BacktraceLine
attr_reader :file
attr_reader :number
attr_reader :method
attr_reader :filtered_file, :filtered_number, :filtered_method
attr_reader :filtered_file, :filtered_number, :filtered_method, :unparsed_line

# Parses a single line of a given backtrace
#
Expand All @@ -47,13 +47,14 @@ def self.parse(unparsed_line, opts = {})

file, number, method = match[1], match[2], match[3]
filtered_args = [fmatch[1], fmatch[2], fmatch[3]]
new(file, number, method, *filtered_args, opts.fetch(:source_radius, 2))
new(unparsed_line, file, number, method, *filtered_args, opts.fetch(:source_radius, 2))
end
end

def initialize(file, number, method, filtered_file = file,
def initialize(unparsed_line, file, number, method, filtered_file = file,
filtered_number = number, filtered_method = method,
source_radius = 2)
self.unparsed_line = unparsed_line
self.filtered_file = filtered_file
self.filtered_number = filtered_number
self.filtered_method = filtered_method
Expand Down Expand Up @@ -87,7 +88,7 @@ def source

private

attr_writer :file, :number, :method, :filtered_file, :filtered_number, :filtered_method
attr_writer :file, :number, :method, :filtered_file, :filtered_number, :filtered_method, :unparsed_line

attr_accessor :source_radius

Expand Down
Empty file.
10 changes: 7 additions & 3 deletions app/views/solid_errors/occurrences/_occurrence.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,13 @@
<% backtrace.lines.each_with_index do |line, i| %>
<%= tag.details open: line.application? || i.zero? do %>
<summary class="hover:bg-gray-50 px-2 py-1 rounded cursor-pointer">
<span class="text-gray-500"><%= File.dirname(line.filtered_file) %>/</span><span class="text-blue-500 font-medium"><%= File.basename(line.filtered_file) %></span>:<span class="text-gray-900 font-medium"><%= line.filtered_number %></span>
<span class="text-gray-500">in</span>
<code class="text-green-500 font-medium"><%= line.filtered_method %></code>
<% if line.filtered_file %>
<span class="text-gray-500"><%= File.dirname(line.filtered_file) %>/</span><span class="text-blue-500 font-medium"><%= File.basename(line.filtered_file) %></span>:<span class="text-gray-900 font-medium"><%= line.filtered_number %></span>
<span class="text-gray-500">in</span>
<code class="text-green-500 font-medium"><%= line.filtered_method %></code>
<% else %>
<span class="text-gray-500"><%= line.unparsed_line %>
<% end %>
</summary>
<div><pre class="flex overflow-auto rounded-b-lg bg-slate-800 p-4 text-sm leading-normal text-white sm:rounded-t-lg"><code class="flex flex-col min-h-full min-w-content px-0"><% line.source.each do |n, code| %>
<div class="line"><span class="mr-2 text-right select-none text-gray-600"><%= n %></span><span><%= code %></span></div>
Expand Down

0 comments on commit 638001e

Please sign in to comment.