diff --git a/client/grpc_client.go b/client/grpc_client.go index 6a53cb21a..f7889d69a 100644 --- a/client/grpc_client.go +++ b/client/grpc_client.go @@ -104,7 +104,7 @@ func (cli *grpcClient) StopForError(err error) { func (cli *grpcClient) Error() error { cli.mtx.Lock() defer cli.mtx.Unlock() - return cli.err + return errors.Wrap(cli.err, types.HumanCode(types.CodeType_InternalError)) } // Set listener for all responses @@ -270,18 +270,12 @@ func (cli *grpcClient) SetOptionSync(key string, value string) (log string, err func (cli *grpcClient) DeliverTxSync(tx []byte) (*types.ResponseDeliverTx, error) { reqres := cli.DeliverTxAsync(tx) - if err := cli.Error(); err != nil { - return nil, errors.Wrap(err, types.HumanCode(types.CodeType_InternalError)) - } - return reqres.Response.GetDeliverTx(), nil + return reqres.Response.GetDeliverTx(), cli.Error() } func (cli *grpcClient) CheckTxSync(tx []byte) (*types.ResponseCheckTx, error) { reqres := cli.CheckTxAsync(tx) - if err := cli.Error(); err != nil { - return nil, errors.Wrap(err, types.HumanCode(types.CodeType_InternalError)) - } - return reqres.Response.GetCheckTx(), nil + return reqres.Response.GetCheckTx(), cli.Error() } func (cli *grpcClient) QuerySync(req types.RequestQuery) (*types.ResponseQuery, error) { @@ -291,10 +285,7 @@ func (cli *grpcClient) QuerySync(req types.RequestQuery) (*types.ResponseQuery, func (cli *grpcClient) CommitSync() (*types.ResponseCommit, error) { reqres := cli.CommitAsync() - if err := cli.Error(); err != nil { - return nil, errors.Wrap(err, types.HumanCode(types.CodeType_InternalError)) - } - return reqres.Response.GetCommit(), nil + return reqres.Response.GetCommit(), cli.Error() } func (cli *grpcClient) InitChainSync(params types.RequestInitChain) error { diff --git a/client/socket_client.go b/client/socket_client.go index 7e117d228..716ef4510 100644 --- a/client/socket_client.go +++ b/client/socket_client.go @@ -116,7 +116,7 @@ func (cli *socketClient) StopForError(err error) { func (cli *socketClient) Error() error { cli.mtx.Lock() defer cli.mtx.Unlock() - return cli.err + return errors.Wrap(cli.err, types.HumanCode(types.CodeType_InternalError)) } // Set listener for all responses @@ -306,19 +306,13 @@ func (cli *socketClient) SetOptionSync(key string, value string) (log string, er func (cli *socketClient) DeliverTxSync(tx []byte) (*types.ResponseDeliverTx, error) { reqres := cli.queueRequest(types.ToRequestDeliverTx(tx)) cli.FlushSync() - if err := cli.Error(); err != nil { - return nil, errors.Wrap(err, types.HumanCode(types.CodeType_InternalError)) - } - return reqres.Response.GetDeliverTx(), nil + return reqres.Response.GetDeliverTx(), cli.Error() } func (cli *socketClient) CheckTxSync(tx []byte) (*types.ResponseCheckTx, error) { reqres := cli.queueRequest(types.ToRequestCheckTx(tx)) cli.FlushSync() - if err := cli.Error(); err != nil { - return nil, errors.Wrap(err, types.HumanCode(types.CodeType_InternalError)) - } - return reqres.Response.GetCheckTx(), nil + return reqres.Response.GetCheckTx(), cli.Error() } func (cli *socketClient) QuerySync(req types.RequestQuery) (*types.ResponseQuery, error) { @@ -330,10 +324,7 @@ func (cli *socketClient) QuerySync(req types.RequestQuery) (*types.ResponseQuery func (cli *socketClient) CommitSync() (*types.ResponseCommit, error) { reqres := cli.queueRequest(types.ToRequestCommit()) cli.FlushSync() - if err := cli.Error(); err != nil { - return nil, errors.Wrap(err, types.HumanCode(types.CodeType_InternalError)) - } - return reqres.Response.GetCommit(), nil + return reqres.Response.GetCommit(), cli.Error() } func (cli *socketClient) InitChainSync(params types.RequestInitChain) error {