-
Notifications
You must be signed in to change notification settings - Fork 802
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
CLI cleanup: exit-1 on error, and use consistent error printing everywhere #6322
Merged
Conversation
This file contains 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
Groxx
requested review from
Shaddoll,
neil-xie,
davidporter-id-au,
shijiesheng,
jakobht,
3vilhamster,
sankari165,
dkrotx,
taylanisikdemir and
demirkayaender
as code owners
October 2, 2024 04:05
Groxx
force-pushed
the
errrets
branch
2 times, most recently
from
October 2, 2024 04:24
d5176a0
to
12b462a
Compare
…where Contains three major changes: 1. creates some standard "literally all CLIs" tooling in common/commoncli (to avoid conflicts with "common" and "cli") 2. moves `cli.NewApp()` and `PrintableError` into commoncli (as `New` and `Problem`) 3. fancy shmancy wrapped error printing with indentation, nested-error cleanup, and colors (we had colors before) 1 and 2 are pretty straightforward, and I've added a simple lint to block using urfave directly to make CLIs (to prevent future accidents). 3 is an attempt at "what if our error messages were similar but less bad". And it also serves as an example of what you can do with enough force with wrapped errors.
3vilhamster
reviewed
Oct 2, 2024
shijiesheng
reviewed
Oct 2, 2024
3vilhamster
approved these changes
Oct 3, 2024
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.
Clean-up and follow-up from #6285 and #6318, but only part 1 of [probably 2].
The next part will change our ErrorAndExit calls into error returns, so we get chains of causes rather than just one message when a fatal error is hit.
If there's a part 3, maybe it'll use https://github.com/bracesdev/errtrace or a https://github.com/pkg/errors-like wrapper to collect useful stack traces along with the error returns, to bring back
CADENCE_CLI_SHOW_STACKS
for all errors.Contains three major changes:
cli.NewApp()
andPrintableError
into commoncli (asNew
andProblem
)1 and 2 are pretty straightforward, and I've added a simple lint to block using urfave directly to make CLIs (to prevent accidentally using it in the future).
3 is an attempt at "what if our error messages were similar but less bad".
And it also serves as an example of what you can do with enough force with wrapped errors.
Ultimately, this gives us (the ability to) have errors print like this:
Rather than like this:
Because it looks "in the same spirit" as the printing before, but is hopefully more readable.
And hopefully it also helps show enough error-spelunking details that someone can figure out much fancier and more structured errors later, if desired.
This also ends up changing the main server binary to use this same fancy error printing, where before it did not:
vs before:
which seems like probably a positive change. It is colorized, but fatih is smart enough to remove it when piped, and removing color from this binary all the time is fairly easy if we want.