internal/ethapi: add errorCode to revert error
This commit is contained in:
committed by
Péter Szilágyi
parent
cc37ce796b
commit
d9b4bc76d4
@ -434,9 +434,11 @@ func (b *bridge) Send(call jsre.Call) (goja.Value, error) {
|
||||
}
|
||||
}
|
||||
case rpc.Error:
|
||||
setError(resp, err.ErrorCode(), err.Error())
|
||||
case rpc.DataError:
|
||||
resp.Set("error", map[string]interface{}{"code": -32603, "message": err.Error(), "data": err.ErrorData()})
|
||||
errMap := map[string]interface{}{"code": err.ErrorCode(), "message": err.Error()}
|
||||
if dataErr, ok := err.(rpc.DataError); ok {
|
||||
errMap["data"] = dataErr.ErrorData()
|
||||
}
|
||||
resp.Set("error", errMap)
|
||||
default:
|
||||
setError(resp, -32603, err.Error())
|
||||
}
|
||||
|
@ -868,6 +868,7 @@ var _ rpc.DataError = (*revertError)(nil)
|
||||
|
||||
type revertError struct {
|
||||
err string // The error string
|
||||
code int // optional error code
|
||||
errData interface{} // additional data
|
||||
}
|
||||
|
||||
@ -875,6 +876,10 @@ func (e revertError) Error() string {
|
||||
return e.err
|
||||
}
|
||||
|
||||
func (e revertError) ErrorCode() int {
|
||||
return e.code
|
||||
}
|
||||
|
||||
func (e revertError) ErrorData() interface{} {
|
||||
return e.errData
|
||||
}
|
||||
|
Reference in New Issue
Block a user