From d3f96dc720bcda6a3db45c69f6ff4ff66cac5ec0 Mon Sep 17 00:00:00 2001 From: Taylor Gerring Date: Fri, 13 Mar 2015 10:03:48 -0400 Subject: Consolidate error type switch --- rpc/http.go | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) (limited to 'rpc') 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 -- cgit