mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-19 11:20:45 +00:00
Take data from the same object
This commit is contained in:
parent
2c5136b794
commit
c471e3c571
1 changed files with 6 additions and 5 deletions
11
rpc/json.go
11
rpc/json.go
|
|
@ -126,12 +126,13 @@ func errorMessage(err error) *jsonrpcMessage {
|
||||||
Code: errcodeDefault,
|
Code: errcodeDefault,
|
||||||
Message: err.Error(),
|
Message: err.Error(),
|
||||||
}}
|
}}
|
||||||
var ec Error
|
var rpcError Error
|
||||||
if errors.As(err, &ec) {
|
if errors.As(err, &rpcError) {
|
||||||
msg.Error.Code = ec.ErrorCode()
|
msg.Error.Code = rpcError.ErrorCode()
|
||||||
}
|
}
|
||||||
var de DataError
|
// Type assert on rpcError to ensure that both code and data come from the same error object.
|
||||||
if errors.As(err, &de) {
|
de, ok := rpcError.(DataError)
|
||||||
|
if ok {
|
||||||
msg.Error.Data = de.ErrorData()
|
msg.Error.Data = de.ErrorData()
|
||||||
}
|
}
|
||||||
return msg
|
return msg
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue