add error handling for InvalidArgument error from sendResponse()

This commit is contained in:
Yuxuan Li 2017-04-06 14:40:53 -07:00
parent 1d27587e10
commit aad28b3c55
1 changed files with 13 additions and 0 deletions

View File

@ -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 {
// TODO: Translate error into a status.Status error if necessary?
// 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
}
if trInfo != nil {