You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

21 lines
350 B
Go

package grpcx
import (
"github.com/pkg/errors"
"google.golang.org/grpc/status"
)
func WrapGrpcErr(e error) (code int32, msg string, err error) {
err = e
cause := errors.Cause(err)
gStatus, ok := status.FromError(cause)
if ok {
code = int32(gStatus.Code())
msg = gStatus.Message()
} else {
code = 500
msg = cause.Error()
}
return
}