fix trace set error bugs
This commit is contained in:
25
server.go
25
server.go
@ -256,7 +256,8 @@ func (s *Server) processUnaryRPC(t transport.ServerTransport, stream *transport.
|
|||||||
traceInfo.firstLine.client = false
|
traceInfo.firstLine.client = false
|
||||||
traceInfo.tr.LazyLog(&traceInfo.firstLine, false)
|
traceInfo.tr.LazyLog(&traceInfo.firstLine, false)
|
||||||
defer func() {
|
defer func() {
|
||||||
if err != nil || err != io.EOF {
|
// We only log the first operation err and dosen't log the application error
|
||||||
|
if err != nil && err != io.EOF {
|
||||||
traceInfo.tr.LazyLog(&fmtStringer{"%v", []interface{}{err}}, true)
|
traceInfo.tr.LazyLog(&fmtStringer{"%v", []interface{}{err}}, true)
|
||||||
traceInfo.tr.SetError()
|
traceInfo.tr.SetError()
|
||||||
}
|
}
|
||||||
@ -309,23 +310,22 @@ func (s *Server) processUnaryRPC(t transport.ServerTransport, stream *transport.
|
|||||||
Delay: false,
|
Delay: false,
|
||||||
}
|
}
|
||||||
if err := s.sendResponse(t, stream, reply, compressionNone, opts); err != nil {
|
if err := s.sendResponse(t, stream, reply, compressionNone, opts); err != nil {
|
||||||
if _, ok := err.(transport.ConnectionError); ok {
|
switch err := err.(type) {
|
||||||
return err
|
case transport.ConnectionError:
|
||||||
}
|
// Nothing to do here.
|
||||||
if e, ok := err.(transport.StreamError); ok {
|
case transport.StreamError:
|
||||||
statusCode = e.Code
|
statusCode = err.Code
|
||||||
statusDesc = e.Desc
|
statusDesc = err.Desc
|
||||||
return err
|
default:
|
||||||
} else {
|
|
||||||
statusCode = codes.Unknown
|
statusCode = codes.Unknown
|
||||||
statusDesc = err.Error()
|
statusDesc = err.Error()
|
||||||
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return t.WriteStatus(stream, statusCode, statusDesc)
|
|
||||||
if traceInfo.tr != nil {
|
if traceInfo.tr != nil {
|
||||||
traceInfo.tr.LazyLog(&payload{sent: true, msg: reply}, true)
|
traceInfo.tr.LazyLog(&payload{sent: true, msg: reply}, true)
|
||||||
}
|
}
|
||||||
|
return t.WriteStatus(stream, statusCode, statusDesc)
|
||||||
default:
|
default:
|
||||||
panic(fmt.Sprintf("payload format to be supported: %d", pf))
|
panic(fmt.Sprintf("payload format to be supported: %d", pf))
|
||||||
}
|
}
|
||||||
@ -363,12 +363,11 @@ func (s *Server) processStreamingRPC(t transport.ServerTransport, stream *transp
|
|||||||
if err, ok := appErr.(rpcError); ok {
|
if err, ok := appErr.(rpcError); ok {
|
||||||
ss.statusCode = err.code
|
ss.statusCode = err.code
|
||||||
ss.statusDesc = err.desc
|
ss.statusDesc = err.desc
|
||||||
return err
|
|
||||||
} else {
|
} else {
|
||||||
ss.statusCode = convertCode(appErr)
|
ss.statusCode = convertCode(appErr)
|
||||||
ss.statusDesc = appErr.Error()
|
ss.statusDesc = appErr.Error()
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
return t.WriteStatus(ss.s, ss.statusCode, ss.statusDesc)
|
return t.WriteStatus(ss.s, ss.statusCode, ss.statusDesc)
|
||||||
|
|
||||||
|
@ -338,10 +338,12 @@ func (ss *serverStream) RecvMsg(m interface{}) (err error) {
|
|||||||
if err == nil {
|
if err == nil {
|
||||||
ss.traceInfo.tr.LazyLog(&payload{sent: false, msg: m}, true)
|
ss.traceInfo.tr.LazyLog(&payload{sent: false, msg: m}, true)
|
||||||
} else {
|
} else {
|
||||||
|
if err != io.EOF {
|
||||||
ss.traceInfo.tr.LazyLog(&fmtStringer{"%v", []interface{}{err}}, true)
|
ss.traceInfo.tr.LazyLog(&fmtStringer{"%v", []interface{}{err}}, true)
|
||||||
ss.traceInfo.tr.SetError()
|
ss.traceInfo.tr.SetError()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
ss.mu.Unlock()
|
ss.mu.Unlock()
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
Reference in New Issue
Block a user