Pretty error reporting#696
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
Add an optional flag to to enable pretty rust-like error reporting for butane errors. This introduces the flags: - pretty-errors (auto, always, or never) - color / colour (auto, always, or never) While also respecting the `NO_COLOR` environment variable.
06bfc24 to
e7e102d
Compare
travier
left a comment
There was a problem hiding this comment.
This looks great to me. +1 from me. Untested.
Should we have this on by default? Butane output should be for humans so good default for humans sounds like a good idea. |
I did not enable it by default in case the raw output was being used in any automatic things. But if its meant for humans only, then having it by default may be nice, as otherwise a lot of people may not know it is available. Open to going either way. |
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.