Display a line in application code instead of gems
まだ誰も着手していません。
- 主要言語
- Ruby
- スター
- 155
- フォーク
- 37
- 平均マージ
- 4日 2時間
- マージ済み PR(30日)
- 1
説明
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.
コントリビューションガイド
このリポジトリのコントリビューションガイドは索引されていません
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず、error_highlight における現在の最深フレームの選択と、issue で議論されている Ruby Kernel#raise の挙動を調べてください。提案されている all-frames、skip-frame、snippet-only、trace-skipping のアプローチを比較します。ただし、issue ではファイルやテストが指定されておらず、合意された完了条件も定められていないことに注意してください。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- ruby
- 領域
- devtools
- issue の種類
- 機能追加
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 活発さ
- 停滞
- 明瞭さ
- 説明が足りない
- 初心者へのやさしさ
- 25/100