diff options
author | Martin Polden <mpolden@mpolden.no> | 2022-09-22 12:42:17 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-22 12:42:17 +0200 |
commit | 82190cc52c30cbb9fdb1b70997cd8e2839937aa6 (patch) | |
tree | 3c9516d883d7dd209e80a9c72a490cd3045bcb2a /client/go | |
parent | 1cd33e80d4612693141a84eadde068a17641d3f9 (diff) | |
parent | 87fc07af7b1620aaa781061622d8efe6a64459a1 (diff) |
Merge pull request #24164 from vespa-engine/arnej/handle-simple-panic
on panic(err), just print the message and exit
Diffstat (limited to 'client/go')
-rw-r--r-- | client/go/script-utils/main.go | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/client/go/script-utils/main.go b/client/go/script-utils/main.go index c80e04e9a0b..10d77da6aea 100644 --- a/client/go/script-utils/main.go +++ b/client/go/script-utils/main.go @@ -20,6 +20,7 @@ func basename(s string) string { } func main() { + defer handleSimplePanic() action := basename(os.Args[0]) if action == "script-utils" && len(os.Args) > 1 { action = os.Args[1] @@ -58,3 +59,14 @@ func main() { fmt.Fprintln(os.Stderr, "(also: vespa-deploy, vespa-logfmt)") } } + +func handleSimplePanic() { + if r := recover(); r != nil { + if je, ok := r.(error); ok { + fmt.Fprintln(os.Stderr, je) + os.Exit(1) + } else { + panic(r) + } + } +} |