|
|
@ -2,7 +2,6 @@ package nstatus
|
|
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"context"
|
|
|
|
"github.com/pkg/errors"
|
|
|
|
|
|
|
|
"google.golang.org/grpc"
|
|
|
|
"google.golang.org/grpc"
|
|
|
|
"google.golang.org/grpc/codes"
|
|
|
|
"google.golang.org/grpc/codes"
|
|
|
|
"google.golang.org/grpc/metadata"
|
|
|
|
"google.golang.org/grpc/metadata"
|
|
|
@ -16,8 +15,7 @@ func UnaryServerInterceptor() grpc.UnaryServerInterceptor {
|
|
|
|
return func(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (resp interface{}, err error) {
|
|
|
|
return func(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (resp interface{}, err error) {
|
|
|
|
resp, err = handler(ctx, req)
|
|
|
|
resp, err = handler(ctx, req)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
cause := errors.Cause(err)
|
|
|
|
e := ConvertErr(err)
|
|
|
|
e := ConvertErr(cause)
|
|
|
|
|
|
|
|
if e != nil {
|
|
|
|
if e != nil {
|
|
|
|
writeResultTypeCtx(ctx, e)
|
|
|
|
writeResultTypeCtx(ctx, e)
|
|
|
|
// 转换为grpc-err
|
|
|
|
// 转换为grpc-err
|
|
|
|