fix(proxyd): Fix compliance with JSON-RPC 2.0 spec by adding optional RPCError.Data (#3683)
* fix: add optional data field to RPCError struct * fix: formatting lint * feat(proxyd): add changeset
This commit is contained in:
parent
7cadaca188
commit
15a59bad99
@ -57,6 +57,7 @@ func (r *RPCRes) MarshalJSON() ([]byte, error) {
|
|||||||
type RPCErr struct {
|
type RPCErr struct {
|
||||||
Code int `json:"code"`
|
Code int `json:"code"`
|
||||||
Message string `json:"message"`
|
Message string `json:"message"`
|
||||||
|
Data string `json:"data,omitempty"`
|
||||||
HTTPErrorCode int `json:"-"`
|
HTTPErrorCode int `json:"-"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ func TestRPCResJSON(t *testing.T) {
|
|||||||
`{"jsonrpc":"2.0","result":null,"id":123}`,
|
`{"jsonrpc":"2.0","result":null,"id":123}`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"error result",
|
"error result without data",
|
||||||
&RPCRes{
|
&RPCRes{
|
||||||
JSONRPC: JSONRPCVersion,
|
JSONRPC: JSONRPCVersion,
|
||||||
Error: &RPCErr{
|
Error: &RPCErr{
|
||||||
@ -56,6 +56,19 @@ func TestRPCResJSON(t *testing.T) {
|
|||||||
},
|
},
|
||||||
`{"jsonrpc":"2.0","error":{"code":1234,"message":"test err"},"id":123}`,
|
`{"jsonrpc":"2.0","error":{"code":1234,"message":"test err"},"id":123}`,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"error result with data",
|
||||||
|
&RPCRes{
|
||||||
|
JSONRPC: JSONRPCVersion,
|
||||||
|
Error: &RPCErr{
|
||||||
|
Code: 1234,
|
||||||
|
Message: "test err",
|
||||||
|
Data: "revert",
|
||||||
|
},
|
||||||
|
ID: []byte("123"),
|
||||||
|
},
|
||||||
|
`{"jsonrpc":"2.0","error":{"code":1234,"message":"test err","data":"revert"},"id":123}`,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"string ID",
|
"string ID",
|
||||||
&RPCRes{
|
&RPCRes{
|
||||||
|
Loading…
Reference in New Issue
Block a user