Pretty error reporting#696
Open
angelcerveraroldan wants to merge 1 commit intocoreos:mainfrom
Open
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces a new reporting package to provide enhanced, "pretty" error messages with source code context and ANSI colorization. The main entry point is updated to track input filenames and utilize these formatting options. Key feedback points include resolving a package name conflict that prevents compilation, implementing bounds checking for string slicing to avoid runtime panics, dynamically managing colorization for non-TTY outputs, and ensuring error underlines remain visible when pointing to whitespace.
251c107 to
01ef686
Compare
9649621 to
474396f
Compare
474396f to
06bfc24
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The goal of this PR is to add pretty error reporting, since the difference is visual, I have attached screenshots for the errors that butane would report for the following butane:
How errors show without this feature:
How errors show with the new feature:
New flags added:
--pretty-errorsto turn on pretty error reporting--color[=WHEN], where WHEN is auto (default), always, or never. This follows the same convention asls,ripgrep,diff,bat,exa, ... In auto mode, colors are disabled if stderr is not a terminal or if the NO_COLOR environment variable is set. It also acceptscolourjust in caseThis is an early PR to get feedback on whether or not this is a good addition to butane, or if it should go somewhere else / nowhere. I am not sure if the current flag name
pretty-errorsis good or not, seems kind of verbose to me.