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:
|
case rpc.Error:
|
||||||
setError(resp, err.ErrorCode(), err.Error())
|
errMap := map[string]interface{}{"code": err.ErrorCode(), "message": err.Error()}
|
||||||
case rpc.DataError:
|
if dataErr, ok := err.(rpc.DataError); ok {
|
||||||
resp.Set("error", map[string]interface{}{"code": -32603, "message": err.Error(), "data": err.ErrorData()})
|
errMap["data"] = dataErr.ErrorData()
|
||||||
|
}
|
||||||
|
resp.Set("error", errMap)
|
||||||
default:
|
default:
|
||||||
setError(resp, -32603, err.Error())
|
setError(resp, -32603, err.Error())
|
||||||
}
|
}
|
||||||
|
@ -868,6 +868,7 @@ var _ rpc.DataError = (*revertError)(nil)
|
|||||||
|
|
||||||
type revertError struct {
|
type revertError struct {
|
||||||
err string // The error string
|
err string // The error string
|
||||||
|
code int // optional error code
|
||||||
errData interface{} // additional data
|
errData interface{} // additional data
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -875,6 +876,10 @@ func (e revertError) Error() string {
|
|||||||
return e.err
|
return e.err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (e revertError) ErrorCode() int {
|
||||||
|
return e.code
|
||||||
|
}
|
||||||
|
|
||||||
func (e revertError) ErrorData() interface{} {
|
func (e revertError) ErrorData() interface{} {
|
||||||
return e.errData
|
return e.errData
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user