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