From c471e3c571b2329d0b05f96656d1578fe51dba95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Miko=C5=82ajczyk?= Date: Wed, 6 May 2026 14:49:34 +0200 Subject: [PATCH] Take data from the same object --- rpc/json.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/rpc/json.go b/rpc/json.go index 3e116be8c5..e661f6aad2 100644 --- a/rpc/json.go +++ b/rpc/json.go @@ -126,12 +126,13 @@ func errorMessage(err error) *jsonrpcMessage { Code: errcodeDefault, Message: err.Error(), }} - var ec Error - if errors.As(err, &ec) { - msg.Error.Code = ec.ErrorCode() + var rpcError Error + if errors.As(err, &rpcError) { + msg.Error.Code = rpcError.ErrorCode() } - var de DataError - if errors.As(err, &de) { + // Type assert on rpcError to ensure that both code and data come from the same error object. + de, ok := rpcError.(DataError) + if ok { msg.Error.Data = de.ErrorData() } return msg