From 03a3f986ffb63184fec97ba0faefd7821f946f4e Mon Sep 17 00:00:00 2001 From: Denis Kirillov Date: Tue, 20 Jul 2021 13:40:39 +0300 Subject: [PATCH] [#30] Fix not found responses Signed-off-by: Denis Kirillov --- downloader/download.go | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/downloader/download.go b/downloader/download.go index 87a1094..cd5e87c 100644 --- a/downloader/download.go +++ b/downloader/download.go @@ -18,8 +18,6 @@ import ( "github.com/nspcc-dev/neofs-sdk-go/pkg/pool" "github.com/valyala/fasthttp" "go.uber.org/zap" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/status" ) type ( @@ -210,12 +208,13 @@ func (r *request) handleNeoFSErr(err error, start time.Time) { for unwrap := errors.Unwrap(err); unwrap != nil; unwrap = errors.Unwrap(cause) { cause = unwrap } - if st, ok := status.FromError(cause); ok && st != nil { - if st.Code() == codes.NotFound { - code = fasthttp.StatusNotFound - } - msg = st.Message() + + if strings.Contains(cause.Error(), "not found") || + strings.Contains(cause.Error(), "can't fetch container info") { + code = fasthttp.StatusNotFound + msg = errObjectNotFound.Error() } + r.Error(msg, code) }