summaryrefslogtreecommitdiffstats
path: root/client
diff options
context:
space:
mode:
authorArne Juul <arnej@yahooinc.com>2022-09-21 14:56:36 +0000
committerArne Juul <arnej@yahooinc.com>2022-09-21 14:56:36 +0000
commit87fc07af7b1620aaa781061622d8efe6a64459a1 (patch)
tree09a19a0b0332c997308fef2812d7daaa647efcba /client
parentd9db475220d68a54ba2c9f820d3bae78f80abd96 (diff)
on panic(err), just print the message and exit
Diffstat (limited to 'client')
-rw-r--r--client/go/script-utils/main.go12
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)
+ }
+ }
+}