use xerrors.As

This commit is contained in:
whyrusleeping 2020-07-23 11:48:48 -07:00
parent 72fe8cb479
commit d547bd9f83

View File

@ -5,6 +5,7 @@ import (
"os"
"github.com/urfave/cli/v2"
"golang.org/x/xerrors"
)
type PrintHelpErr struct {
@ -36,8 +37,8 @@ func RunApp(app *cli.App) {
} else {
fmt.Printf("ERROR: %s\n\n", err)
}
phe, ok := err.(*PrintHelpErr)
if ok {
var phe *PrintHelpErr
if xerrors.As(err, &phe) {
cli.ShowCommandHelp(phe.Ctx, phe.Ctx.Command.Name)
}
os.Exit(1)