-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
feat: added custom error handler function #1751
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmm interesting.
The code looks good, but I want to understand what this is trying to solve.
Can you provide a sample cobra program where something like this would be useful? Seems like you'd want to set this per command to handle different errors from different commands differently?
@jpmcb thanks for your feedback. i created a gist where i can show you an example where this feature would be useful: https://gist.github.com/alexraileanu/200a4473653efa8fbda6e555bd3fc428. in the screenshot below, you can see that my custom error handlers have different colored messages, however the please let me know if you need any more clarification as i would really like to make use of this feature :) |
@jpmcb @marckhouzam kindly requesting a review of this as i'd very much like to have this feature in my project |
17e813a
to
d4040ad
Compare
@jpmcb sorry for the mess, i did some mistakes on my side of github but it looks like it's all good now. |
The Cobra project currently lacks enough contributors to adequately respond to all PRs. This bot triages issues and PRs according to the following rules:
|
As we have very few maintainers, and those have very little time, we've decided to remove the auto-close configuration. |
Sometimes I want to manually define a way that an error is presented to the user (for instance to change color output and such). This PR adds a way to do so via the new
SetErrorHandlerFunc
method