Skip to content
Myr

Merge pull request #244 from apriendeau/silence-errors-readme

Before adoption: this commit came in with the history the project adopted, so no landing records it.

updates readme to Explain SilenceErrors and SilenceUsage #225

authored by Eric Paris · committed by Eric Paris · parents d6b4812, e21e5f0 · Browse files · 1 file+6 added−1 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+6 added−1 removed

  • other:+6 added−1 removed

1 file+6 added−1 removed

modified:README.md+6 added-1 removed
711 unmodified lines
712713714## Alternative Error Handling715716Cobra also has functions where the return signature is an error. This allows for errors to bubble up to the top, providing a way to handle the errors in one location. The current list of functions that return an error is:716Cobra also has functions where the return signature is an error. This allows for errors to bubble up to the top,717providing a way to handle the errors in one location. The current list of functions that return an error is:718719* PersistentPreRunE720* PreRunE721* RunE722* PostRunE723* PersistentPostRunE724725If you would like to silence the default `error` and `usage` output in favor of your own, you can set `SilenceUsage`726and `SilenceErrors` to `false` on the command. A child command respects these flags if they are set on the parent727command.728729**Example Usage using RunE:**730731```go732package main
145 unmodified lines