Display a line in application code instead of gems
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Ruby
- Sterne
- 155
- Forks
- 37
- Ø Merge
- 4 T. 2 Std.
- Gemergte PRs (30 T.)
- 1
Beschreibung
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.
Beitragsleitfaden
Für dieses Repository ist kein Beitragsleitfaden indexiert
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne damit, die aktuelle Auswahl des tiefsten Frames in error_highlight und das im Issue diskutierte Verhalten von Ruby Kernel#raise zu untersuchen. Vergleiche die vorgeschlagenen Ansätze all-frames, skip-frame, snippet-only und trace-skipping, beachte aber, dass der Issue keine Dateien oder Tests nennt und keine vereinbarte Abschlussbedingung festlegt.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- ruby
- Bereich
- devtools
- Issue-Typ
- Feature
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Aktivitätsstatus
- Veraltet
- Klarheit
- Muss geklärt werden
- Anfängerfreundlichkeit
- 25/100