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
|
return nil
|
||||||
case msg.isCall():
|
case msg.isCall():
|
||||||
resp := h.handleCall(ctx, msg)
|
resp := h.handleCall(ctx, msg)
|
||||||
|
var ctx []interface{}
|
||||||
|
ctx = append(ctx, "reqid", idForLog{msg.ID}, "t", time.Since(start))
|
||||||
if resp.Error != nil {
|
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 {
|
} else {
|
||||||
h.log.Debug("Served "+msg.Method, "reqid", idForLog{msg.ID}, "t", time.Since(start))
|
h.log.Debug("Served "+msg.Method, ctx...)
|
||||||
}
|
}
|
||||||
return resp
|
return resp
|
||||||
case msg.hasValidID():
|
case msg.hasValidID():
|
||||||
|
@ -139,6 +139,10 @@ func (err *jsonError) ErrorCode() int {
|
|||||||
return err.Code
|
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.
|
// Conn is a subset of the methods of net.Conn which are sufficient for ServerCodec.
|
||||||
type Conn interface {
|
type Conn interface {
|
||||||
io.ReadWriteCloser
|
io.ReadWriteCloser
|
||||||
|
Reference in New Issue
Block a user