From 14183379b66150e729974405d4f0ae09e1e821c5 Mon Sep 17 00:00:00 2001 From: Ciprian Dorin Craciun Date: Wed, 15 Dec 2021 19:57:24 +0200 Subject: [PATCH] [main] Try to catch panics and print them without stacktraces. --- sources/lib/common/main.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/sources/lib/common/main.go b/sources/lib/common/main.go index 764cffb..e47a5fe 100644 --- a/sources/lib/common/main.go +++ b/sources/lib/common/main.go @@ -14,7 +14,13 @@ import "os" func Main_0 (_main func () (error)) () { log.SetFlags (0) - log.SetPrefix (fmt.Sprintf ("[%8d] ", os.Getpid ())) + + defer func () () { + if _panic := recover (); _panic != nil { + log.Printf ("[ee] [279a6e2e] %s\n", _panic) + AbortError (nil, "[5bcae27c] unexpected panic!") + } + } () if _error := _main (); _error == nil { os.Exit (0)