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

Add error() for displaying errors from client code #1675

merged 6 commits into from Jan 14, 2022


Copy link

@shadowspawn shadowspawn commented Jan 8, 2022

Pull Request


People adding extra error checks do not have a way to take advantage of the error configuration built into Commander such as: .configureOutput(), .exitOverride(), .showHelpAfterError().

There have not been many requests for this, but we do now have quite rich error handling which clients can use for their own errors too.

Related: #1358 #1632


Provide a low level routine that is also used by Commander itself. Refactor private ._displayError() into public .error(). Change the signature to make the error id code and exitCode optional so can be called with just a message.

if (cmd.opts().good && cmd.opts().bad)
  cmd.error('error: specify just one of "--good" and "--bad"');


  • add error() for generating errors from client code just like Commander generated errors, with support for .configureOutput(), .exitOverride(), and .showHelpAfterError()

@shadowspawn shadowspawn added the semver: major label Jan 8, 2022
@shadowspawn shadowspawn marked this pull request as ready for review Jan 13, 2022
Copy link

@abetomo abetomo left a comment


@shadowspawn shadowspawn merged commit 7a59df4 into tj:release/9.x Jan 14, 2022
12 checks passed
@shadowspawn shadowspawn deleted the feature/error2 branch Jan 14, 2022
Copy link
Collaborator Author

shadowspawn commented Jan 14, 2022

Thanks @abetomo
I will do another prerelease soon. No other changes in mind!

@shadowspawn shadowspawn added the pending release label Jan 14, 2022
@shadowspawn shadowspawn added this to the Commander v9.0.0 milestone Jan 14, 2022
Copy link
Collaborator Author

shadowspawn commented Jan 14, 2022

.error() is included in prerelease Commander v9.0.0-1. Show resolved Hide resolved
@shadowspawn shadowspawn removed the pending release label Jan 29, 2022
Copy link
Collaborator Author

shadowspawn commented Jan 29, 2022

Commander v9 has been released.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
semver: major
None yet

Successfully merging this pull request may close these issues.

None yet

3 participants