mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-06-06 06:58:39 +00:00
Use errors.As
This commit is contained in:
parent
aaa2b66285
commit
2c5136b794
1 changed files with 4 additions and 4 deletions
|
|
@ -126,12 +126,12 @@ func errorMessage(err error) *jsonrpcMessage {
|
||||||
Code: errcodeDefault,
|
Code: errcodeDefault,
|
||||||
Message: err.Error(),
|
Message: err.Error(),
|
||||||
}}
|
}}
|
||||||
ec, ok := err.(Error)
|
var ec Error
|
||||||
if ok {
|
if errors.As(err, &ec) {
|
||||||
msg.Error.Code = ec.ErrorCode()
|
msg.Error.Code = ec.ErrorCode()
|
||||||
}
|
}
|
||||||
de, ok := err.(DataError)
|
var de DataError
|
||||||
if ok {
|
if errors.As(err, &de) {
|
||||||
msg.Error.Data = de.ErrorData()
|
msg.Error.Data = de.ErrorData()
|
||||||
}
|
}
|
||||||
return msg
|
return msg
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue