mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-05-24 08:49:29 +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,
|
||||
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
|
||||
|
|
|
|||
Loading…
Reference in a new issue