-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
How to Run without exiting on error? #565
Comments
@ebuchman agreed, we should support this use case. For now you can workaround it by setting |
Perviously app.Run() would exit only if the command opted in to it by returning an error that implemented ExitCoder. Otherwise it would return that error to the caller for it to handle. Now HandleExitCoder always exits if err != nil, meaning that app.Run() only ever returns nil. It looks like an API change (added in f41708) and probably a bug to me, rather than something that needs an enhancement or hack to work around. |
@wttw yeah, I took a deeper dive in and tend to agree with you that the original intent was to only exit if it satisfied Long story short, I agree that this is a bug. We'll need to be careful about releasing this though, since some people may have started to depend on this behavior. |
Doing so limits the ability for users to have only some of their errors cause the application to terminate while allowing others to bubble up. This was originally an adjustment to #361 in #496 to fix #495, but, in hindsight, I believe that the better approach is to recommend the use of `RunAndExitOnError` for this use case (which is undeprecated here). Fixes #565 #594
Currently it appears that if a command returns an error,
Run
will exit the program, since it calls HandleExitCoder, which always exits if the error is not nil. Is it possible to receive that error without exiting? For instance, I've implemented an interactive console that uses this library - the console should not exit just because a command returned an errorThe text was updated successfully, but these errors were encountered: