Skip to content
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

fix(cli): improve cli error handling #1687

Merged
merged 9 commits into from
Apr 7, 2022
Merged

Conversation

ansgarm
Copy link
Member

@ansgarm ansgarm commented Apr 5, 2022

  • chore(deps): update yargs type defs
  • fix(cli): be explicit about yargs not exiting the process on failure
  • fix(cli): make stack positional argument optional
  • fix(cli): exit the process on uncaught errors from yargs handlers
  • fix(cli): throw Usage error instead of local process.exit()
  • refactor(cli): Don't catch errors locally in command handlers as they are now caught properly on a global level in .fail()

Exiting the process has already implicitly been disabled by passing
a callback to `.fail()`. Now this is more explicit.
previously this caused .fail() to be called with a message (but no error) which in turn caused debug information to be printed without cancelling the process itself. Another commit will fix this and stop everything if argument validation fails
and print validation messages and abort in that case as well
… are now caught properly on a global level in .fail()
@ansgarm ansgarm changed the title improve cli error handling fix(cli): improve cli error handling Apr 5, 2022
…ks things after changing positional arguments to optional
@ansgarm
Copy link
Member Author

ansgarm commented Apr 5, 2022

CI currently fails because somehow yargs tries to run the command when returning completions for it (see yargs/yargs#1965). I'm going to implement the workaround mentioned in the issue in a base command class.

@ansgarm ansgarm merged commit ae5a652 into main Apr 7, 2022
@ansgarm ansgarm deleted the improve-cli-error-handling branch April 7, 2022 09:31
@github-actions
Copy link
Contributor

I'm going to lock this pull request because it has been closed for 30 days. This helps our maintainers find and focus on the active issues. If you've found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 29, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants