From 9e67c471dfac0857ca7478825f0cdb7b164c3118 Mon Sep 17 00:00:00 2001 From: Marina Biryukova Date: Tue, 24 Sep 2024 16:31:56 +0300 Subject: [PATCH] [#xxx] client: Return status from all methods Since status is checked first in handleError method, it should be returned from client methods Signed-off-by: Marina Biryukova --- client/apemanager_list_chains.go | 2 +- client/netmap.go | 8 ++------ client/object_delete.go | 8 ++------ client/object_get.go | 8 ++------ client/object_hash.go | 8 ++------ client/object_put_raw.go | 8 ++------ client/object_put_single.go | 2 +- 7 files changed, 12 insertions(+), 32 deletions(-) diff --git a/client/apemanager_list_chains.go b/client/apemanager_list_chains.go index a608f1e..a8a3e8a 100644 --- a/client/apemanager_list_chains.go +++ b/client/apemanager_list_chains.go @@ -65,7 +65,7 @@ func (c *Client) APEManagerListChains(ctx context.Context, prm PrmAPEManagerList var res ResAPEManagerListChains res.st, err = c.processResponse(resp) if err != nil || !apistatus.IsSuccessful(res.st) { - return nil, err + return &res, err } for _, ch := range resp.GetBody().GetChains() { diff --git a/client/netmap.go b/client/netmap.go index 8bedf46..a870ab2 100644 --- a/client/netmap.go +++ b/client/netmap.go @@ -239,12 +239,8 @@ func (c *Client) NetMapSnapshot(ctx context.Context, _ PrmNetMapSnapshot) (*ResN var res ResNetMapSnapshot res.st, err = c.processResponse(resp) - if err != nil { - return nil, err - } - - if !apistatus.IsSuccessful(res.st) { - return &res, nil + if err != nil || !apistatus.IsSuccessful(res.st) { + return &res, err } const fieldNetMap = "network map" diff --git a/client/object_delete.go b/client/object_delete.go index a9fe8e8..3214cff 100644 --- a/client/object_delete.go +++ b/client/object_delete.go @@ -148,12 +148,8 @@ func (c *Client) ObjectDelete(ctx context.Context, prm PrmObjectDelete) (*ResObj var res ResObjectDelete res.st, err = c.processResponse(resp) - if err != nil { - return nil, err - } - - if !apistatus.IsSuccessful(res.st) { - return &res, nil + if err != nil || !apistatus.IsSuccessful(res.st) { + return &res, err } const fieldTombstone = "tombstone" diff --git a/client/object_get.go b/client/object_get.go index 8c821de..ba4f72d 100644 --- a/client/object_get.go +++ b/client/object_get.go @@ -492,12 +492,8 @@ func (c *Client) ObjectHead(ctx context.Context, prm PrmObjectHead) (*ResObjectH var res ResObjectHead res.st, err = c.processResponse(resp) - if err != nil { - return nil, err - } - - if !apistatus.IsSuccessful(res.st) { - return &res, nil + if err != nil || !apistatus.IsSuccessful(res.st) { + return &res, err } res.idObj = *prm.ObjectID diff --git a/client/object_hash.go b/client/object_hash.go index 108e0ce..b1b9ffc 100644 --- a/client/object_hash.go +++ b/client/object_hash.go @@ -189,12 +189,8 @@ func (c *Client) ObjectHash(ctx context.Context, prm PrmObjectHash) (*ResObjectH var res ResObjectHash res.st, err = c.processResponse(resp) - if err != nil { - return nil, err - } - - if !apistatus.IsSuccessful(res.st) { - return &res, nil + if err != nil || !apistatus.IsSuccessful(res.st) { + return &res, err } res.checksums = resp.GetBody().GetHashList() diff --git a/client/object_put_raw.go b/client/object_put_raw.go index c22bd05..e47c6a2 100644 --- a/client/object_put_raw.go +++ b/client/object_put_raw.go @@ -156,12 +156,8 @@ func (x *objectWriterRaw) Close(_ context.Context) (*ResObjectPut, error) { } x.res.st, x.err = x.client.processResponse(&x.respV2) - if x.err != nil { - return nil, x.err - } - - if !apistatus.IsSuccessful(x.res.st) { - return &x.res, nil + if x.err != nil || !apistatus.IsSuccessful(x.res.st) { + return &x.res, x.err } const fieldID = "ID" diff --git a/client/object_put_single.go b/client/object_put_single.go index bdef026..a2ff8a0 100644 --- a/client/object_put_single.go +++ b/client/object_put_single.go @@ -167,7 +167,7 @@ func (c *Client) ObjectPutSingle(ctx context.Context, prm PrmObjectPutSingle) (* var res ResObjectPutSingle res.st, err = c.processResponse(resp) if err != nil { - return nil, err + return &res, err } res.epoch = resp.GetMetaHeader().GetEpoch()