From 1f65bb27ca41f2e6e7ab6231c864fcee96e2b3bd Mon Sep 17 00:00:00 2001 From: "Eduardo W. da Cunha" Date: Mon, 3 Jun 2024 20:55:05 -0300 Subject: [PATCH] added a method for jsonError struct that always returns data from errors --- rpc/client.go | 2 +- rpc/json.go | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/rpc/client.go b/rpc/client.go index 05b87ae96c..4bf092c34b 100644 --- a/rpc/client.go +++ b/rpc/client.go @@ -364,7 +364,7 @@ func (c *Client) CallContext(ctx context.Context, result interface{}, method str resp := batchresp[0] switch { case resp.Error != nil: - return resp.Error + return resp.Error.FullError() case len(resp.Result) == 0: return ErrNoResult default: diff --git a/rpc/json.go b/rpc/json.go index e932389d17..15d392a872 100644 --- a/rpc/json.go +++ b/rpc/json.go @@ -157,6 +157,10 @@ func (err *jsonError) ErrorData() interface{} { 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. type Conn interface { io.ReadWriteCloser