From 87d19f09f7438837810d74d04356c9dfd5342771 Mon Sep 17 00:00:00 2001 From: Angira Kekteeva Date: Wed, 8 Jun 2022 10:05:07 +0400 Subject: [PATCH] [#519] Fix transform of AcessDenied error Signed-off-by: Angira Kekteeva --- internal/neofs/neofs.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/internal/neofs/neofs.go b/internal/neofs/neofs.go index 4977417c..6c11400e 100644 --- a/internal/neofs/neofs.go +++ b/internal/neofs/neofs.go @@ -268,6 +268,10 @@ func (x *NeoFS) CreateObject(ctx context.Context, prm layer.PrmObjectCreate) (*o idObj, err := x.pool.PutObject(ctx, prmPut) if err != nil { + reason, ok := isErrAccessDenied(err) + if ok { + return nil, fmt.Errorf("%w: %s", layer.ErrAccessDenied, reason) + } return nil, fmt.Errorf("save object via connection pool: %w", err) } @@ -467,6 +471,12 @@ func (x *NeoFS) DeleteObject(ctx context.Context, prm layer.PrmObjectDelete) err } func isErrAccessDenied(err error) (string, bool) { + unwrappedErr := errors.Unwrap(err) + for unwrappedErr != nil { + err = unwrappedErr + unwrappedErr = errors.Unwrap(err) + } + switch err := err.(type) { default: return "", false