diff options
author | Taylor Gerring <taylor.gerring@gmail.com> | 2015-03-13 22:03:48 +0800 |
---|---|---|
committer | Taylor Gerring <taylor.gerring@gmail.com> | 2015-03-13 22:03:48 +0800 |
commit | d3f96dc720bcda6a3db45c69f6ff4ff66cac5ec0 (patch) | |
tree | 2273111223f7a4d6ee0539789a0807c1a955a325 /rpc | |
parent | 0932f843830a30ea3da5d866fbe4e459d2748b1e (diff) | |
download | dexon-d3f96dc720bcda6a3db45c69f6ff4ff66cac5ec0.tar dexon-d3f96dc720bcda6a3db45c69f6ff4ff66cac5ec0.tar.gz dexon-d3f96dc720bcda6a3db45c69f6ff4ff66cac5ec0.tar.bz2 dexon-d3f96dc720bcda6a3db45c69f6ff4ff66cac5ec0.tar.lz dexon-d3f96dc720bcda6a3db45c69f6ff4ff66cac5ec0.tar.xz dexon-d3f96dc720bcda6a3db45c69f6ff4ff66cac5ec0.tar.zst dexon-d3f96dc720bcda6a3db45c69f6ff4ff66cac5ec0.zip |
Consolidate error type switch
Diffstat (limited to 'rpc')
-rw-r--r-- | rpc/http.go | 16 |
1 files changed, 2 insertions, 14 deletions
diff --git a/rpc/http.go b/rpc/http.go index 8b45319ff..8dcd55ad1 100644 --- a/rpc/http.go +++ b/rpc/http.go @@ -34,15 +34,7 @@ func JSONRPC(pipe *xeth.XEth, dataDir string) http.Handler { switch reqerr.(type) { case nil: break - case *DecodeParamError: - 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: + case *DecodeParamError, *InsufficientParamsError, *ValidationError: jsonerr := &RpcErrorObject{-32602, reqerr.Error()} json.Send(w, &RpcErrorResponse{JsonRpc: jsonrpcver, ID: nil, Error: jsonerr}) return @@ -61,11 +53,7 @@ func JSONRPC(pipe *xeth.XEth, dataDir string) http.Handler { jsonerr := &RpcErrorObject{-32601, reserr.Error()} json.Send(w, &RpcErrorResponse{JsonRpc: jsonrpcver, ID: reqParsed.ID, Error: jsonerr}) return - case *InsufficientParamsError: - jsonerr := &RpcErrorObject{-32602, reserr.Error()} - json.Send(w, &RpcErrorResponse{JsonRpc: jsonrpcver, ID: reqParsed.ID, Error: jsonerr}) - return - case *ValidationError: + case *DecodeParamError, *InsufficientParamsError, *ValidationError: jsonerr := &RpcErrorObject{-32602, reserr.Error()} json.Send(w, &RpcErrorResponse{JsonRpc: jsonrpcver, ID: reqParsed.ID, Error: jsonerr}) return |