Improve error handling in /commands #1502

Closed
bep opened this Issue Oct 17, 2015 · 1 comment

Comments

Projects
None yet
2 participants
@bep
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 added the Enhancement label Oct 17, 2015

@bep bep self-assigned this Oct 17, 2015

@bep

This comment has been minimized.

Show comment
Hide comment
Member

bep commented Oct 17, 2015

bep added a commit to bep/hugo that referenced this issue Dec 2, 2015

Improve error handling in commands
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 #1502

@anthonyfok anthonyfok added this to the v0.16 milestone Dec 2, 2015

@bep bep closed this 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

One more error fix in the server command
And some other small code clean-up.

See #1502

bep added a commit that referenced this issue Dec 2, 2015

bramp added a commit to bramp/hugo that referenced this issue Dec 17, 2015

Improve error handling in commands
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 #1502

bramp added a commit to bramp/hugo that referenced this issue Dec 17, 2015

bramp added a commit to bramp/hugo that referenced this issue Dec 17, 2015

One more error fix in the server command
And some other small code clean-up.

See #1502

bramp added a commit to bramp/hugo that referenced this issue Dec 17, 2015

tychoish added a commit to tychoish/hugo that referenced this issue Aug 13, 2017

Improve error handling in commands
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 #1502

tychoish added a commit to tychoish/hugo that referenced this issue Aug 13, 2017

tychoish added a commit to tychoish/hugo that referenced this issue Aug 13, 2017

One more error fix in the server command
And some other small code clean-up.

See #1502

tychoish added a commit to tychoish/hugo that referenced this issue Aug 13, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment