Compare commits

..

1 commit

Author SHA1 Message Date
1b67ab9608 [#275] client: Return status from all methods
All checks were successful
DCO / DCO (pull_request) Successful in 52s
Tests and linters / Tests (pull_request) Successful in 1m0s
Tests and linters / Lint (pull_request) Successful in 1m55s
Since status is checked first in handleError method, it should be returned from client methods

Signed-off-by: Marina Biryukova <m.biryukova@yadro.com>
2024-09-24 18:29:32 +03:00
6 changed files with 6 additions and 30 deletions

View file

@ -239,14 +239,10 @@ func (c *Client) NetMapSnapshot(ctx context.Context, _ PrmNetMapSnapshot) (*ResN
var res ResNetMapSnapshot
res.st, err = c.processResponse(resp)
if err != nil {
if err != nil || !apistatus.IsSuccessful(res.st) {
return &res, err
}
if !apistatus.IsSuccessful(res.st) {
return &res, nil
}
const fieldNetMap = "network map"
netMapV2 := resp.GetBody().NetMap()

View file

@ -148,14 +148,10 @@ func (c *Client) ObjectDelete(ctx context.Context, prm PrmObjectDelete) (*ResObj
var res ResObjectDelete
res.st, err = c.processResponse(resp)
if err != nil {
if err != nil || !apistatus.IsSuccessful(res.st) {
return &res, err
}
if !apistatus.IsSuccessful(res.st) {
return &res, nil
}
const fieldTombstone = "tombstone"
idTombV2 := resp.GetBody().GetTombstone().GetObjectID()

View file

@ -492,14 +492,10 @@ func (c *Client) ObjectHead(ctx context.Context, prm PrmObjectHead) (*ResObjectH
var res ResObjectHead
res.st, err = c.processResponse(resp)
if err != nil {
if err != nil || !apistatus.IsSuccessful(res.st) {
return &res, err
}
if !apistatus.IsSuccessful(res.st) {
return &res, nil
}
res.idObj = *prm.ObjectID
switch v := resp.GetBody().GetHeaderPart().(type) {

View file

@ -189,14 +189,10 @@ func (c *Client) ObjectHash(ctx context.Context, prm PrmObjectHash) (*ResObjectH
var res ResObjectHash
res.st, err = c.processResponse(resp)
if err != nil {
if err != nil || !apistatus.IsSuccessful(res.st) {
return &res, err
}
if !apistatus.IsSuccessful(res.st) {
return &res, nil
}
res.checksums = resp.GetBody().GetHashList()
if len(res.checksums) == 0 {
return nil, newErrMissingResponseField("hash list")

View file

@ -246,14 +246,10 @@ func (x *objectPatcher) Close(_ context.Context) (*ResObjectPatch, error) {
}
x.res.st, x.err = x.client.processResponse(&x.respV2)
if x.err != nil {
if x.err != nil || !apistatus.IsSuccessful(x.res.st) {
return &x.res, x.err
}
if !apistatus.IsSuccessful(x.res.st) {
return &x.res, nil
}
const fieldID = "ID"
idV2 := x.respV2.Body.ObjectID

View file

@ -156,14 +156,10 @@ func (x *objectWriterRaw) Close(_ context.Context) (*ResObjectPut, error) {
}
x.res.st, x.err = x.client.processResponse(&x.respV2)
if x.err != nil {
if x.err != nil || !apistatus.IsSuccessful(x.res.st) {
return &x.res, x.err
}
if !apistatus.IsSuccessful(x.res.st) {
return &x.res, nil
}
const fieldID = "ID"
idV2 := x.respV2.GetBody().GetObjectID()