grpc client/server fixes (#1355)
* grpc client/server fixes Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
parent
0e1d8c4e47
commit
84a19c5dff
27
error.go
27
error.go
@ -17,18 +17,21 @@ func microError(err error) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// grpc error
|
// grpc error
|
||||||
if s, ok := status.FromError(err); ok {
|
s, ok := status.FromError(err)
|
||||||
details := s.Details()
|
if !ok {
|
||||||
if len(details) == 0 {
|
return err
|
||||||
if e := errors.Parse(s.Message()); e.Code > 0 {
|
|
||||||
return e // actually a micro error
|
|
||||||
}
|
|
||||||
return errors.InternalServerError("go.micro.client", s.Message())
|
|
||||||
}
|
|
||||||
// return first error from details
|
|
||||||
return details[0].(error)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// do nothing
|
// return first error from details
|
||||||
return err
|
if details := s.Details(); len(details) > 0 {
|
||||||
|
return microError(details[0].(error))
|
||||||
|
}
|
||||||
|
|
||||||
|
// try to decode micro *errors.Error
|
||||||
|
if e := errors.Parse(s.Message()); e.Code > 0 {
|
||||||
|
return e // actually a micro error
|
||||||
|
}
|
||||||
|
|
||||||
|
// fallback
|
||||||
|
return errors.InternalServerError("go.micro.client", s.Message())
|
||||||
}
|
}
|
||||||
|
2
grpc.go
2
grpc.go
@ -465,11 +465,11 @@ func (g *grpcClient) Call(ctx context.Context, req client.Request, rsp interface
|
|||||||
|
|
||||||
// make the call
|
// make the call
|
||||||
err = gcall(ctx, node, req, rsp, callOpts)
|
err = gcall(ctx, node, req, rsp, callOpts)
|
||||||
|
g.opts.Selector.Mark(service, node, err)
|
||||||
if verr, ok := err.(*errors.Error); ok {
|
if verr, ok := err.(*errors.Error); ok {
|
||||||
return verr
|
return verr
|
||||||
}
|
}
|
||||||
|
|
||||||
g.opts.Selector.Mark(service, node, err)
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user