Skip to content

Commit

Permalink
Merge pull request #168 from danielgtaylor/fix-recover-err
Browse files Browse the repository at this point in the history
fix: properly set error on panic recovery
  • Loading branch information
danielgtaylor authored Jan 18, 2023
2 parents d60e6d9 + 6d5a3ba commit c6a3394
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -682,7 +682,7 @@ func Defaults() {
}

// Run the CLI! Parse arguments, make requests, print responses.
func Run() error {
func Run() (returnErr error) {
// We need to register new commands at runtime based on the selected API
// so that we don't have to potentially refresh and parse every single
// registered API just to run. So this is a little hacky, but we hijack
Expand Down Expand Up @@ -798,8 +798,6 @@ func Run() error {
}
}

var returnErr error

// Phew, we made it. Execute the command now that everything is loaded
// and all the relevant sub-commands are registered.
defer func() {
Expand All @@ -808,6 +806,8 @@ func Run() error {
LogDebug("%s", string(debug.Stack()))
if e, ok := err.(error); ok {
returnErr = e
} else {
returnErr = fmt.Errorf("%v", err)
}
}
}()
Expand Down

0 comments on commit c6a3394

Please sign in to comment.