From 7465a4a131ff29fd04e8da7cf18f5daf85c8a866 Mon Sep 17 00:00:00 2001 From: Peter Broadhurst Date: Sun, 4 Aug 2024 18:23:20 -0400 Subject: [PATCH] Ensure returning error from failed serialize of params Signed-off-by: Peter Broadhurst --- pkg/rpcbackend/wsbackend.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/pkg/rpcbackend/wsbackend.go b/pkg/rpcbackend/wsbackend.go index 006201b0..713b53ae 100644 --- a/pkg/rpcbackend/wsbackend.go +++ b/pkg/rpcbackend/wsbackend.go @@ -343,12 +343,14 @@ func (rc *wsRPCClient) Subscriptions() []Subscription { } func (rc *wsRPCClient) sendRPC(ctx context.Context, reqID string, rpcReq *RPCRequest) *RPCError { - jsonInput, _ := json.Marshal(rpcReq) - log.L(ctx).Debugf("RPC[%s] --> %s", reqID, rpcReq.Method) - if logrus.IsLevelEnabled(logrus.TraceLevel) { - log.L(ctx).Tracef("RPC[%s] INPUT: %s", reqID, jsonInput) + jsonInput, err := json.Marshal(rpcReq) + if err == nil { + log.L(ctx).Debugf("RPC[%s] --> %s", reqID, rpcReq.Method) + if logrus.IsLevelEnabled(logrus.TraceLevel) { + log.L(ctx).Tracef("RPC[%s] INPUT: %s", reqID, jsonInput) + } + err = rc.client.Send(ctx, jsonInput) } - err := rc.client.Send(ctx, jsonInput) if err != nil { rpcErr := NewRPCError(ctx, RPCCodeInternalError, signermsgs.MsgRPCRequestFailed, err) log.L(ctx).Errorf("RPC[%s] <-- ERROR: %s", reqID, err)