mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-04-25 02:52:23 +00:00
Consolidate error type switch
This commit is contained in:
parent
0932f84383
commit
d3f96dc720
1 changed files with 2 additions and 14 deletions
16
rpc/http.go
16
rpc/http.go
|
|
@ -34,15 +34,7 @@ func JSONRPC(pipe *xeth.XEth, dataDir string) http.Handler {
|
||||||
switch reqerr.(type) {
|
switch reqerr.(type) {
|
||||||
case nil:
|
case nil:
|
||||||
break
|
break
|
||||||
case *DecodeParamError:
|
case *DecodeParamError, *InsufficientParamsError, *ValidationError:
|
||||||
jsonerr := &RpcErrorObject{-32602, reqerr.Error()}
|
|
||||||
json.Send(w, &RpcErrorResponse{JsonRpc: jsonrpcver, ID: nil, Error: jsonerr})
|
|
||||||
return
|
|
||||||
case *InsufficientParamsError:
|
|
||||||
jsonerr := &RpcErrorObject{-32602, reqerr.Error()}
|
|
||||||
json.Send(w, &RpcErrorResponse{JsonRpc: jsonrpcver, ID: nil, Error: jsonerr})
|
|
||||||
return
|
|
||||||
case *ValidationError:
|
|
||||||
jsonerr := &RpcErrorObject{-32602, reqerr.Error()}
|
jsonerr := &RpcErrorObject{-32602, reqerr.Error()}
|
||||||
json.Send(w, &RpcErrorResponse{JsonRpc: jsonrpcver, ID: nil, Error: jsonerr})
|
json.Send(w, &RpcErrorResponse{JsonRpc: jsonrpcver, ID: nil, Error: jsonerr})
|
||||||
return
|
return
|
||||||
|
|
@ -61,11 +53,7 @@ func JSONRPC(pipe *xeth.XEth, dataDir string) http.Handler {
|
||||||
jsonerr := &RpcErrorObject{-32601, reserr.Error()}
|
jsonerr := &RpcErrorObject{-32601, reserr.Error()}
|
||||||
json.Send(w, &RpcErrorResponse{JsonRpc: jsonrpcver, ID: reqParsed.ID, Error: jsonerr})
|
json.Send(w, &RpcErrorResponse{JsonRpc: jsonrpcver, ID: reqParsed.ID, Error: jsonerr})
|
||||||
return
|
return
|
||||||
case *InsufficientParamsError:
|
case *DecodeParamError, *InsufficientParamsError, *ValidationError:
|
||||||
jsonerr := &RpcErrorObject{-32602, reserr.Error()}
|
|
||||||
json.Send(w, &RpcErrorResponse{JsonRpc: jsonrpcver, ID: reqParsed.ID, Error: jsonerr})
|
|
||||||
return
|
|
||||||
case *ValidationError:
|
|
||||||
jsonerr := &RpcErrorObject{-32602, reserr.Error()}
|
jsonerr := &RpcErrorObject{-32602, reserr.Error()}
|
||||||
json.Send(w, &RpcErrorResponse{JsonRpc: jsonrpcver, ID: reqParsed.ID, Error: jsonerr})
|
json.Send(w, &RpcErrorResponse{JsonRpc: jsonrpcver, ID: reqParsed.ID, Error: jsonerr})
|
||||||
return
|
return
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue