1
0
mirror of https://github.com/go-micro/go-micro.git synced 2024-12-30 10:10:44 +02:00

Use context to log "panic recovered" errors in grpc-server plugin (#2278)

This commit is contained in:
gregkv 2021-09-20 12:50:13 +03:00 committed by GitHub
parent cb3db7dd83
commit b8fbe87e1f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -398,10 +398,7 @@ func (g *grpcServer) processRequest(stream grpc.ServerStream, service *service,
fn := func(ctx context.Context, req server.Request, rsp interface{}) (err error) {
defer func() {
if r := recover(); r != nil {
if logger.V(logger.ErrorLevel, logger.DefaultLogger) {
logger.Error("panic recovered: ", r)
logger.Error(string(debug.Stack()))
}
logger.Extract(ctx).Errorf("panic recovered: %v, stack: %s", r, string(debug.Stack()))
err = errors.InternalServerError("go.micro.server", "panic recovered: %v", r)
}
}()