rpc: print error data field
This commit is contained in:
committed by
Péter Szilágyi
parent
5048fd1028
commit
c7765c0abb
@ -296,10 +296,16 @@ func (h *handler) handleCallMsg(ctx *callProc, msg *jsonrpcMessage) *jsonrpcMess
|
||||
return nil
|
||||
case msg.isCall():
|
||||
resp := h.handleCall(ctx, msg)
|
||||
var ctx []interface{}
|
||||
ctx = append(ctx, "reqid", idForLog{msg.ID}, "t", time.Since(start))
|
||||
if resp.Error != nil {
|
||||
h.log.Warn("Served "+msg.Method, "reqid", idForLog{msg.ID}, "t", time.Since(start), "err", resp.Error.Message)
|
||||
ctx = append(ctx, "err", resp.Error.Message)
|
||||
if resp.Error.Data != nil {
|
||||
ctx = append(ctx, "errdata", resp.Error.Data)
|
||||
}
|
||||
h.log.Warn("Served "+msg.Method, ctx...)
|
||||
} else {
|
||||
h.log.Debug("Served "+msg.Method, "reqid", idForLog{msg.ID}, "t", time.Since(start))
|
||||
h.log.Debug("Served "+msg.Method, ctx...)
|
||||
}
|
||||
return resp
|
||||
case msg.hasValidID():
|
||||
|
@ -139,6 +139,10 @@ func (err *jsonError) ErrorCode() int {
|
||||
return err.Code
|
||||
}
|
||||
|
||||
func (err *jsonError) ErrorData() interface{} {
|
||||
return err.Data
|
||||
}
|
||||
|
||||
// Conn is a subset of the methods of net.Conn which are sufficient for ServerCodec.
|
||||
type Conn interface {
|
||||
io.ReadWriteCloser
|
||||
|
Reference in New Issue
Block a user