From 5ad0df7794211c891737518dcbf91ec5817c54e9 Mon Sep 17 00:00:00 2001 From: Leonard Lyubich Date: Wed, 21 Oct 2020 12:15:54 +0300 Subject: [PATCH] [#108] object/head: Return 404 error if header was not found Define ErrNotFound error in headsvc package. Return ErrNotFound from Head method if the header was not found in the container. Signed-off-by: Leonard Lyubich --- pkg/services/object/head/distributed.go | 2 +- pkg/services/object/head/service.go | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/pkg/services/object/head/distributed.go b/pkg/services/object/head/distributed.go index 9fe4e0c7a..6ca3b5905 100644 --- a/pkg/services/object/head/distributed.go +++ b/pkg/services/object/head/distributed.go @@ -135,7 +135,7 @@ loop: } if !h.traverser.Success() { - return nil, errors.Errorf("(%T) incomplete object Head operation", h) + return nil, errors.Wrapf(ErrNotFound, "(%T) incomplete object Head operation", h) } return resp, nil diff --git a/pkg/services/object/head/service.go b/pkg/services/object/head/service.go index 18ac0c0f9..535b25dcb 100644 --- a/pkg/services/object/head/service.go +++ b/pkg/services/object/head/service.go @@ -39,6 +39,8 @@ type cfg struct { rightChildSearcher RelationSearcher } +var ErrNotFound = errors.New("object header not found") + func defaultCfg() *cfg { return &cfg{ workerPool: new(util.SyncWorkerPool),