From 6d5a3bab59106e8bfdf0f26c6fa1763149816aa5 Mon Sep 17 00:00:00 2001 From: "Daniel G. Taylor" Date: Tue, 17 Jan 2023 22:18:26 -0800 Subject: [PATCH] fix: properly set error on panic recovery --- cli/cli.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cli/cli.go b/cli/cli.go index 18b91b4..763217a 100644 --- a/cli/cli.go +++ b/cli/cli.go @@ -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 @@ -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() { @@ -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) } } }()