diff options
| author | Jonathan Amsterdam <jba@google.com> | 2023-04-12 10:07:35 -0400 |
|---|---|---|
| committer | Jonathan Amsterdam <jba@google.com> | 2023-04-12 20:35:18 +0000 |
| commit | 38531c6290bfb321d74fa4e48a6e889e29b60dab (patch) | |
| tree | d06fc536175c92d9a3ffb77df8dda4501410bf98 /src/cmd/compile/internal | |
| parent | f3e6f0f296c5d0a317527ebe6471eedabc408fae (diff) | |
| download | go-38531c6290bfb321d74fa4e48a6e889e29b60dab.tar.xz | |
log/slog: catch panics in LogValue
If a LogValue call panics, recover and return an error instead.
The error contains some stack information to make it easier to
find the problem. A number of people complained that panics
in fmt.Formatter.Format functions are hard to debug because
there is no context.
This is an example of the error text:
LogValue panicked
called from log/slog.panickingLogValue.LogValue (/usr/local/google/home/jba/repos/go/src/log/slog/value_test.go:221)
called from log/slog.Value.resolve (/usr/local/google/home/jba/repos/go/src/log/slog/value.go:465)
called from log/slog.Value.Resolve (/usr/local/google/home/jba/repos/go/src/log/slog/value.go:446)
called from log/slog.TestLogValue (/usr/local/google/home/jba/repos/go/src/log/slog/value_test.go:192)
called from testing.tRunner (/usr/local/google/home/jba/repos/go/src/testing/testing.go:1595)
(rest of stack elided)
Fixes #59141.
Change-Id: I62e6ff6968d1aa34873e955c2d606d25418a673b
Reviewed-on: https://go-review.googlesource.com/c/go/+/484097
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
Run-TryBot: Jonathan Amsterdam <jba@google.com>
Diffstat (limited to 'src/cmd/compile/internal')
0 files changed, 0 insertions, 0 deletions
