From 87fc07af7b1620aaa781061622d8efe6a64459a1 Mon Sep 17 00:00:00 2001 From: Arne Juul Date: Wed, 21 Sep 2022 14:56:36 +0000 Subject: on panic(err), just print the message and exit --- client/go/script-utils/main.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'client') 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) + } + } +} -- cgit v1.2.3