use xerrors.As
This commit is contained in:
parent
72fe8cb479
commit
d547bd9f83
@ -5,6 +5,7 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/urfave/cli/v2"
|
"github.com/urfave/cli/v2"
|
||||||
|
"golang.org/x/xerrors"
|
||||||
)
|
)
|
||||||
|
|
||||||
type PrintHelpErr struct {
|
type PrintHelpErr struct {
|
||||||
@ -36,8 +37,8 @@ func RunApp(app *cli.App) {
|
|||||||
} else {
|
} else {
|
||||||
fmt.Printf("ERROR: %s\n\n", err)
|
fmt.Printf("ERROR: %s\n\n", err)
|
||||||
}
|
}
|
||||||
phe, ok := err.(*PrintHelpErr)
|
var phe *PrintHelpErr
|
||||||
if ok {
|
if xerrors.As(err, &phe) {
|
||||||
cli.ShowCommandHelp(phe.Ctx, phe.Ctx.Command.Name)
|
cli.ShowCommandHelp(phe.Ctx, phe.Ctx.Command.Name)
|
||||||
}
|
}
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
|
Loading…
Reference in New Issue
Block a user