diff --git a/command.go b/command.go index 7f036307..6866f7d0 100644 --- a/command.go +++ b/command.go @@ -1099,7 +1099,7 @@ func (c *Command) ExecuteC() (cmd *Command, err error) { // If root command has SilenceErrors flagged, // all subcommands should respect it if !cmd.SilenceErrors && !c.SilenceErrors { - c.PrintErrln(c.ErrPrefix(), err.Error()) + c.PrintErrln(cmd.ErrPrefix(), err.Error()) } // If root command has SilenceUsage flagged, diff --git a/site/content/user_guide.md b/site/content/user_guide.md index 03972bb9..93daadf5 100644 --- a/site/content/user_guide.md +++ b/site/content/user_guide.md @@ -598,8 +598,8 @@ the version template. The template can be customized using the ## Error Message Prefix -Cobra prints an error message when being returned a non-nil error value. -The default error message is `Error: error contents`. +Cobra prints an error message when receiving a non-nil error value. +The default error message is `Error: `. The Prefix, `Error:` can be customized using the `cmd.SetErrPrefix(s string)` function. ## PreRun and PostRun Hooks