mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2025-01-08 18:51:19 +00:00
4e22f52ab3
* hotfix for round robin, hotfix for grpc recovery * gofmt * break * wrong subtraction * lint * testnet fork version update * ignore relay / DHT protocol not supported error
23 lines
635 B
Go
23 lines
635 B
Go
package traceutil
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
"runtime/debug"
|
|
|
|
"github.com/sirupsen/logrus"
|
|
"go.opencensus.io/trace"
|
|
)
|
|
|
|
// RecoveryHandlerFunc is a function that recovers from the panic `p` by returning an `error`.
|
|
// The context can be used to extract request scoped metadata and context values.
|
|
func RecoveryHandlerFunc(ctx context.Context, p interface{}) error {
|
|
span := trace.FromContext(ctx)
|
|
if span != nil {
|
|
span.AddAttributes(trace.StringAttribute("stack", string(debug.Stack())))
|
|
}
|
|
err := errors.New(p.(string))
|
|
logrus.WithError(err).WithField("stack", string(debug.Stack())).Error("gRPC panicked!")
|
|
return err
|
|
}
|