diff --git a/client/client.go b/client/client.go index d2c6053..a334273 100644 --- a/client/client.go +++ b/client/client.go @@ -110,8 +110,11 @@ func (c *Client) CallTimeout(timeout time.Duration, result interface{}, method s select { case <-rs.doneChan: + if nil != rs.clientError { + return rs.clientError + } result = rs.result - return rs.clientError + return nil case <-t.C: rs.cancel() return newError(method, params, fmt.Errorf("%s Timeout", c.logHeader())) @@ -304,10 +307,13 @@ func (c *Client) handleResponse(resCodec protocol.ClientResponseCodec) { return } rs := _rs.(*requestState) - rs.setError(resCodec.Error()) - err := resCodec.Result(rs.result) - if nil != err { - rs.setError(err) + if nil != resCodec.Error() { + rs.setError(resCodec.Error()) + } else { + err := resCodec.Result(rs.result) + if nil != err { + rs.setError(err) + } } rs.done()