Display a line in application code instead of gems
Nobody has claimed this yet.
- Dominant language
- Ruby
- Stars
- 155
- Forks
- 37
- Avg merge
- 4d 2h
- Merged PRs (30d)
- 1
Description
Currently, error_highlight spots the deepest Ruby frame. This may show code in a gem, which may not be very useful for application writers.
Consider:
# gem code
class SomeGem
def foo(x)
raise ArgumentError, "wrong input" if x == nil
end
end
# app code
SomeGem.new.foo(nil)
Here is the current behavior:
$ ruby test.rb
test.rb:4:in `foo': wrong input (ArgumentError)
raise ArgumentError, "wrong input" if x == nil
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
from test.rb:9:in `<main>'
However, application writers may want to see the line of SomeGem.new.foo(nil).
How might this be resolved?
- Display code snippets for all frames, not just for the deepest one. Python does this, but I am not very keen on it because it makes the error trace very messy.
- Add an argument
Kernel#raiseto tell error_highlight which frame should be displayed, for example,raise ArgumentError, "wrong input", error_highlight_skip_frames: 1.
For 2, there are two ways how to show the error.
2-1. Keep the error trace as is and change only the snippet. This might be confusing because the snippet line does not exist in test.rb:4.
$ ruby test.rb
test.rb:4:in `foo': wrong input (ArgumentError)
SomeGem.new.foo(nil)
^^^
from test.rb:9:in `<main>'
2-2. Skip the error trace. This looks good to me, but I think this is beyond the responsibilities of error_highlight.
$ ruby test.rb
test.rb:9:in `<main>': wrong input (ArgumentError)
SomeGem.new.foo(nil)
^^^
I wonder if we should put something like raise skip_frames: n in the Ruby core side? I need to organize my thoughts.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by examining error_highlight's current deepest-frame selection and the Ruby Kernel#raise behavior discussed in the issue. Compare the proposed all-frames, skip-frame, snippet-only, and trace-skipping approaches, but note that the issue does not name files or tests and does not establish an agreed completion condition.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ruby
- Domain
- devtools
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100