From 6e1e00ae3f7154c8fec74c6f702855866de5b5c8 Mon Sep 17 00:00:00 2001 From: CJ Horton Date: Wed, 14 Feb 2024 12:46:15 -0800 Subject: [PATCH] standardize panic output Programs that monitor Terraform's output to report panics might make the reasonable assumption that the string "panic:" is always included and is therefore safe to monitor for. Our custom panic output unfortunately breaks these assumptions at the moment. Instead of asking consumers to add their own handling to deal with this problem, let's add that greppable string to our custom panic output. --- internal/logging/panic.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/logging/panic.go b/internal/logging/panic.go index 0da545be7d..bcc92f12ba 100644 --- a/internal/logging/panic.go +++ b/internal/logging/panic.go @@ -78,7 +78,7 @@ func PanicHandler() { stderr = os.Stderr } fmt.Fprint(stderr, panicOutput) - fmt.Fprint(stderr, recovered, "\n") + fmt.Fprint(stderr, "panic: ", recovered, "\n") // The following mimics the implementation of debug.PrintStack, but // without the hard-coded reference to os.Stderr. stderr.Write(debug.Stack())