Skip to content

Commit

Permalink
🧹 make panic handler more flexible to allow ui message logging (#3137)
Browse files Browse the repository at this point in the history
  • Loading branch information
chris-rock authored Jan 29, 2024
1 parent 24b9901 commit 99ef99a
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion providers-sdk/v1/upstream/health/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down

0 comments on commit 99ef99a

Please sign in to comment.