From 99ef99a1e9be3f402fb8e05e04776cb0dc5089c2 Mon Sep 17 00:00:00 2001 From: Christoph Hartmann Date: Mon, 29 Jan 2024 16:27:10 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=B9=20make=20panic=20handler=20more=20?= =?UTF-8?q?flexible=20to=20allow=20ui=20message=20logging=20(#3137)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- providers-sdk/v1/upstream/health/errors.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/providers-sdk/v1/upstream/health/errors.go b/providers-sdk/v1/upstream/health/errors.go index 9a65a3b935..cf6e2f6b6c 100644 --- a/providers-sdk/v1/upstream/health/errors.go +++ b/providers-sdk/v1/upstream/health/errors.go @@ -15,10 +15,17 @@ import ( //go:generate protoc --proto_path=. --go_out=. --go_opt=paths=source_relative --rangerrpc_out=. errors.proto -func ReportPanic(product, version, build string) { +type PanicReportFn func(product, version, build string, r any, stacktrace []byte) + +func ReportPanic(product, version, build string, reporters ...PanicReportFn) { if r := recover(); r != nil { sendPanic(product, version, build, r, debug.Stack()) + // call additional reporters + for _, reporter := range reporters { + reporter(product, version, build, r, debug.Stack()) + } + // output error to console panic(r) }