Skip to content

Commit

Permalink
Fix exit code 1 on server Ctrl+C
Browse files Browse the repository at this point in the history
  • Loading branch information
feedmeapples committed Feb 24, 2023
1 parent ab85e37 commit 4f516cc
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,19 +64,19 @@ func configureCLI(ctx *cli.Context) error {
}

func HandleError(c *cli.Context, err error) {
if err == nil {
return
if exitErr, ok := err.(cli.ExitCoder); ok {
if exitErr.ExitCode() != 0 {
fmt.Fprintf(os.Stderr, "%s %+v\n", color.Red(c, "Error:"), err)
if os.Getenv(common.ShowErrorStackEnv) != `` {
fmt.Fprintln(os.Stderr, color.Magenta(c, "Stack trace:"))
debug.PrintStack()
} else {
fmt.Fprintf(os.Stderr, "('export %s=1' to see stack traces)\n", common.ShowErrorStackEnv)
}
}
}

fmt.Fprintf(os.Stderr, "%s %+v\n", color.Red(c, "Error:"), err)
if os.Getenv(common.ShowErrorStackEnv) != `` {
fmt.Fprintln(os.Stderr, color.Magenta(c, "Stack trace:"))
debug.PrintStack()
} else {
fmt.Fprintf(os.Stderr, "('export %s=1' to see stack traces)\n", common.ShowErrorStackEnv)
}

cli.OsExiter(1)
cli.HandleExitCoder(err)
}

func commands(defaultCfg *sconfig.Config) []*cli.Command {
Expand Down

0 comments on commit 4f516cc

Please sign in to comment.