add error handling for InvalidArgument error from sendResponse()
This commit is contained in:
13
server.go
13
server.go
@ -777,6 +777,19 @@ func (s *Server) processUnaryRPC(t transport.ServerTransport, stream *transport.
|
|||||||
if err := s.sendResponse(t, stream, reply, s.opts.cp, opts); err != nil {
|
if err := s.sendResponse(t, stream, reply, s.opts.cp, opts); err != nil {
|
||||||
// TODO: Translate error into a status.Status error if necessary?
|
// TODO: Translate error into a status.Status error if necessary?
|
||||||
// TODO: Write status when appropriate.
|
// TODO: Write status when appropriate.
|
||||||
|
s, ok := status.FromError(err)
|
||||||
|
if !ok {
|
||||||
|
// TODO: Parse possible non-status error
|
||||||
|
} else {
|
||||||
|
switch s.Code() {
|
||||||
|
case codes.InvalidArgument:
|
||||||
|
if e := t.WriteStatus(stream, s); e != nil {
|
||||||
|
grpclog.Printf("grpc: Server.processUnaryRPC failed to write status: %v", e)
|
||||||
|
}
|
||||||
|
// TODO: Add cases if needed
|
||||||
|
default:
|
||||||
|
}
|
||||||
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if trInfo != nil {
|
if trInfo != nil {
|
||||||
|
Reference in New Issue
Block a user