Skip to content

Commit

Permalink
Mark frames that are inside root directory
Browse files Browse the repository at this point in the history
The backend will treat these frames in a special way.
  • Loading branch information
kyrylo committed Jun 20, 2024
1 parent 9f78459 commit 7e2b0d2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions lib/telebugs/middleware/root_directory_filter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ def call(report)
next unless (file = frame[:file])
next unless file.start_with?(@root_directory)

frame[:root_dir] = true
file.sub!(/#{@root_directory}\/?/, "")
end
end
Expand Down
4 changes: 3 additions & 1 deletion test/middleware/test_root_directory_filter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ def test_root_directory_filter
report = Telebugs::Report.new(e)
Telebugs::Middleware::RootDirectoryFilter.new(root_directory).call(report)

assert_equal "app/models/user.rb", report.data[:errors][0][:backtrace][0][:file]
frame = report.data[:errors][0][:backtrace][0]
assert_equal "app/models/user.rb", frame[:file]
assert frame[:root_dir]
end
end

0 comments on commit 7e2b0d2

Please sign in to comment.