added a method for jsonError struct that always returns data from errors

This commit is contained in:
Eduardo W. da Cunha 2024-06-03 20:55:05 -03:00
parent a6751d6fc8
commit 1f65bb27ca
2 changed files with 5 additions and 1 deletions

View file

@ -364,7 +364,7 @@ func (c *Client) CallContext(ctx context.Context, result interface{}, method str
resp := batchresp[0] resp := batchresp[0]
switch { switch {
case resp.Error != nil: case resp.Error != nil:
return resp.Error return resp.Error.FullError()
case len(resp.Result) == 0: case len(resp.Result) == 0:
return ErrNoResult return ErrNoResult
default: default:

View file

@ -157,6 +157,10 @@ func (err *jsonError) ErrorData() interface{} {
return err.Data return err.Data
} }
func (err *jsonError) FullError() error {
return fmt.Errorf("message: %v, code: %v, data: %v", err.Message, err.Code, 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