Skip to content

Commit

Permalink
Merge pull request #2120 from OffchainLabs/log-data-error
Browse files Browse the repository at this point in the history
Log error data when available
  • Loading branch information
PlasmaPower authored Feb 1, 2024
2 parents f6dfe98 + e8167fe commit b9043c4
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion util/rpcclient/rpcclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,13 +155,26 @@ func (c *RpcClient) CallContext(ctx_in context.Context, result interface{}, meth
ctx, cancelCtx = context.WithCancel(ctx_in)
}
err = c.client.CallContext(ctx, result, method, args...)

cancelCtx()
logger := log.Trace
limit := int(c.config().ArgLogLimit)
if err != nil && err.Error() != "already known" {
logger = log.Info
}
logger("rpc response", "method", method, "logId", logId, "err", err, "result", limitedMarshal{limit, result}, "attempt", i, "args", limitedArgumentsMarshal{limit, args})
logEntry := []interface{}{
"method", method,
"logId", logId,
"err", err,
"result", limitedMarshal{limit, result},
"attempt", i,
"args", limitedArgumentsMarshal{limit, args},
}
var dataErr rpc.DataError
if errors.As(err, &dataErr) {
logEntry = append(logEntry, "errorData", limitedMarshal{limit, dataErr.ErrorData()})
}
logger("rpc response", logEntry...)
if err == nil {
return nil
}
Expand Down

0 comments on commit b9043c4

Please sign in to comment.