aboutsummaryrefslogtreecommitdiffstats
path: root/rpc/api.go
diff options
context:
space:
mode:
authorTaylor Gerring <taylor.gerring@gmail.com>2015-03-13 08:07:03 +0800
committerTaylor Gerring <taylor.gerring@gmail.com>2015-03-13 08:07:03 +0800
commit094f921e5028fc215efbc86118e3d3e5b0663055 (patch)
treeff99596fcb504014b33191f09ba73fd4c18d55cb /rpc/api.go
parent14bdcd2c052214ca78c7cb163771c780e2fd1291 (diff)
downloadgo-tangerine-094f921e5028fc215efbc86118e3d3e5b0663055.tar.gz
go-tangerine-094f921e5028fc215efbc86118e3d3e5b0663055.tar.zst
go-tangerine-094f921e5028fc215efbc86118e3d3e5b0663055.zip
Convert to proper errors
Allow returning different JSON RPC error codes depending on error type
Diffstat (limited to 'rpc/api.go')
-rw-r--r--rpc/api.go18
1 files changed, 9 insertions, 9 deletions
diff --git a/rpc/api.go b/rpc/api.go
index b94d2d6dc..b72a0dd60 100644
--- a/rpc/api.go
+++ b/rpc/api.go
@@ -578,7 +578,7 @@ func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error
}
return p.Call(args, reply)
case "eth_flush":
- return errNotImplemented
+ return NewNotImplementedError(req.Method)
case "eth_getBlockByHash":
args := new(GetBlockByHashArgs)
if err := json.Unmarshal(req.Params, &args); err != nil {
@@ -618,7 +618,7 @@ func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error
return err
}
if args.Index > int64(len(v.Transactions)) || args.Index < 0 {
- return NewErrorWithMessage(errDecodeArgs, "Transaction index does not exist")
+ return NewValidationError("Index", "does not exist")
}
*reply = v.Transactions[args.Index]
case "eth_getTransactionByBlockNumberAndIndex":
@@ -632,7 +632,7 @@ func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error
return err
}
if args.Index > int64(len(v.Transactions)) || args.Index < 0 {
- return NewErrorWithMessage(errDecodeArgs, "Transaction index does not exist")
+ return NewValidationError("Index", "does not exist")
}
*reply = v.Transactions[args.Index]
case "eth_getUncleByBlockHashAndIndex":
@@ -646,7 +646,7 @@ func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error
return err
}
if args.Index > int64(len(v.Uncles)) || args.Index < 0 {
- return NewErrorWithMessage(errDecodeArgs, "Uncle index does not exist")
+ return NewValidationError("Index", "does not exist")
}
uncle, err := p.GetBlockByHash(toHex(v.Uncles[args.Index]), false)
@@ -665,7 +665,7 @@ func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error
return err
}
if args.Index > int64(len(v.Uncles)) || args.Index < 0 {
- return NewErrorWithMessage(errDecodeArgs, "Uncle index does not exist")
+ return NewValidationError("Index", "does not exist")
}
uncle, err := p.GetBlockByHash(toHex(v.Uncles[args.Index]), false)
@@ -678,7 +678,7 @@ func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error
case "eth_compileSolidity":
case "eth_compileLLL":
case "eth_compileSerpent":
- return errNotImplemented
+ return NewNotImplementedError(req.Method)
case "eth_newFilter":
args := new(FilterOptions)
if err := json.Unmarshal(req.Params, &args); err != nil {
@@ -717,7 +717,7 @@ func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error
return p.AllLogs(args, reply)
case "eth_getWork":
case "eth_submitWork":
- return errNotImplemented
+ return NewNotImplementedError(req.Method)
case "db_put":
args := new(DbArgs)
if err := json.Unmarshal(req.Params, &args); err != nil {
@@ -746,7 +746,7 @@ func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error
return p.HasWhisperIdentity(args.Identity, reply)
case "shh_newGroup":
case "shh_addToGroup":
- return errNotImplemented
+ return NewNotImplementedError(req.Method)
case "shh_newFilter":
args := new(WhisperFilterArgs)
if err := json.Unmarshal(req.Params, &args); err != nil {
@@ -790,7 +790,7 @@ func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error
// }
// return p.WatchTx(args, reply)
default:
- return NewErrorWithMessage(errNotImplemented, req.Method)
+ return NewNotImplementedError(req.Method)
}
rpclogger.DebugDetailf("Reply: %T %s", reply, reply)