Skip to content

Commit

Permalink
fix: Ensure exit status is set by recover func
Browse files Browse the repository at this point in the history
  • Loading branch information
gabe565 committed May 1, 2024
1 parent 67cc4c5 commit 8c9b0be
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,14 @@ var errPanic = errors.New("panic")
func main() {
defer func() {
var err error
var status int
if msg := recover(); msg != nil {
status = 1
err = fmt.Errorf("%w: %v\n\n%s", errPanic, msg, string(debug.Stack()))
_, _ = io.WriteString(os.Stderr, err.Error())
}
util.PostRun(err)
os.Exit(status)
}()

rootCmd := cmd.NewCommand()
Expand Down

0 comments on commit 8c9b0be

Please sign in to comment.