-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Display error highlight in application code instead of gem files #54
Conversation
(I'm taking a look at the prism failure) |
Thanks, but #35 is a really harder problem than I first thought. There are two sub issues in #35: (1) which stack frame to display snippets for, and (2) how to display error messages. For (1), this PR checks the file path of each frame to skip gem files unconditionally. TBH, I don't like this approach. Since the Ruby interpreter does not have a clear distinction between gem code and app code, I am not comfortable with error_highlight making such a distinction on its own. Also, I have no certainty if it is really useful for the application author. In #35, I wrote So, now I don't have a good idea how to go about #35. Should we provide a configurable API for which frames to be skipped? But I am afraid that such an API will be regretted later. For (2), this PR does nothing. However, I find the following error message quite confusing:
Seeing this, few users will understand that the snippet is in test.rb:2. I wonder if we should put the snippet after
This may be easy to understand, but unfortunately, the current API of |
Thanks so much for sharing these thoughts, @mame!
It’s harder than I thought, too. I’ve been thinking about it over the past few days.
Indeed, we have no certainty on that point—it’s something that’s been echoing in my mind as well. --
With that in mind, here’s a thought: what if we showed two frames instead of one? This might provide the author a bit more context:
This way, someone could look at the root error and still see the relevant piece of the app code. What do you think about this approach? (It's not so verbose as Python, and still provides extra clues for the author. Also, personally, I find error traces very helpful for pinpointing the root cause, so I’ve tried to avoid interpolating the stack trace with the snippet) --
I’ve noticed that I think using something like -- Really curious to hear your thoughts about this proposal. I’m happy to evolve it in a different direction or pause this a bit if we're not entirely on board with any of these paths—we can always revisit this in the future as well :) Thanks again for your thoughts! |
Closing this PR for now, as I don't think we're quite there yet. |
Fixes #35
This PR updates the
ErrorHighlight.spot
method to use the first line that doesn't belong to a Gem file.Before
![](https://private-user-images.githubusercontent.com/1079279/380918642-6a83f12a-67fa-4702-b29d-6a4468f5e1d3.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiw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