Merge pull request #1117 from creekorful/harmonize-error-handling
Harmonize BeforeError handling
This commit is contained in:
commit
464c868816
2
app.go
2
app.go
@ -292,8 +292,6 @@ func (a *App) RunContext(ctx context.Context, arguments []string) (err error) {
|
|||||||
if a.Before != nil {
|
if a.Before != nil {
|
||||||
beforeErr := a.Before(context)
|
beforeErr := a.Before(context)
|
||||||
if beforeErr != nil {
|
if beforeErr != nil {
|
||||||
_, _ = fmt.Fprintf(a.Writer, "%v\n\n", beforeErr)
|
|
||||||
_ = ShowAppHelp(context)
|
|
||||||
a.handleExitCoder(context, beforeErr)
|
a.handleExitCoder(context, beforeErr)
|
||||||
err = beforeErr
|
err = beforeErr
|
||||||
return err
|
return err
|
||||||
|
@ -150,7 +150,6 @@ func (c *Command) Run(ctx *Context) (err error) {
|
|||||||
if c.Before != nil {
|
if c.Before != nil {
|
||||||
err = c.Before(context)
|
err = c.Before(context)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
_ = ShowCommandHelp(context, c.Name)
|
|
||||||
context.App.handleExitCoder(context, err)
|
context.App.handleExitCoder(context, err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user