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

Improve error handling in /commands #1502

Closed
bep opened this issue Oct 17, 2015 · 2 comments
Closed

Improve error handling in /commands #1502

bep opened this issue Oct 17, 2015 · 2 comments
Assignees
Milestone

Comments

@bep
Copy link
Member

bep commented Oct 17, 2015

See 9d603ce

The commands package is full of these constructions.

Cobra now has a RunE func that can be used to a better job with these:

https://github.com/spf13/cobra/blob/master/command.go#L82

@bep bep self-assigned this Oct 17, 2015
@bep
Copy link
Member Author

bep commented Oct 17, 2015

spf13/cobra#168

bep added a commit to bep/hugo that referenced this issue Dec 2, 2015
Cobra, the CLI commander in use in Hugo, has some long awaited improvements in the error handling department.
This enables a more centralized error handling approach.

This commit introduces that by changing all the command funcs to `RunE`:

* The core part of the error logging, usage logging and `os.Exit(-1)` is now performed in one place and that one place only.
* The usage text is now only shown on invalid arguments etc. (user errors)

Fixes gohugoio#1502
@anthonyfok anthonyfok added this to the v0.16 milestone Dec 2, 2015
@bep bep closed this as completed in 3f0f7ee Dec 2, 2015
bep added a commit that referenced this issue Dec 2, 2015
anthonyfok added a commit that referenced this issue Dec 2, 2015
And some other small code clean-up.

See #1502
bep added a commit that referenced this issue Dec 2, 2015
bramp pushed a commit to bramp/hugo that referenced this issue Dec 17, 2015
Cobra, the CLI commander in use in Hugo, has some long awaited improvements in the error handling department.
This enables a more centralized error handling approach.

This commit introduces that by changing all the command funcs to `RunE`:

* The core part of the error logging, usage logging and `os.Exit(-1)` is now performed in one place and that one place only.
* The usage text is now only shown on invalid arguments etc. (user errors)

Fixes gohugoio#1502
bramp pushed a commit to bramp/hugo that referenced this issue Dec 17, 2015
bramp pushed a commit to bramp/hugo that referenced this issue Dec 17, 2015
And some other small code clean-up.

See gohugoio#1502
bramp pushed a commit to bramp/hugo that referenced this issue Dec 17, 2015
tychoish pushed a commit to tychoish/hugo that referenced this issue Aug 13, 2017
Cobra, the CLI commander in use in Hugo, has some long awaited improvements in the error handling department.
This enables a more centralized error handling approach.

This commit introduces that by changing all the command funcs to `RunE`:

* The core part of the error logging, usage logging and `os.Exit(-1)` is now performed in one place and that one place only.
* The usage text is now only shown on invalid arguments etc. (user errors)

Fixes gohugoio#1502
tychoish pushed a commit to tychoish/hugo that referenced this issue Aug 13, 2017
tychoish pushed a commit to tychoish/hugo that referenced this issue Aug 13, 2017
And some other small code clean-up.

See gohugoio#1502
tychoish pushed a commit to tychoish/hugo that referenced this issue Aug 13, 2017
@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

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

Successfully merging a pull request may close this issue.

2 participants