forked from TrueCloudLab/frostfs-http-gw
Merge pull request #80 from KirillovDenis/bugfix/30-correct_404_error
[#30] Fix not found responses
This commit is contained in:
commit
4d3d80f007
1 changed files with 6 additions and 7 deletions
|
@ -18,8 +18,6 @@ import (
|
||||||
"github.com/nspcc-dev/neofs-sdk-go/pkg/pool"
|
"github.com/nspcc-dev/neofs-sdk-go/pkg/pool"
|
||||||
"github.com/valyala/fasthttp"
|
"github.com/valyala/fasthttp"
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
"google.golang.org/grpc/codes"
|
|
||||||
"google.golang.org/grpc/status"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type (
|
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) {
|
for unwrap := errors.Unwrap(err); unwrap != nil; unwrap = errors.Unwrap(cause) {
|
||||||
cause = unwrap
|
cause = unwrap
|
||||||
}
|
}
|
||||||
if st, ok := status.FromError(cause); ok && st != nil {
|
|
||||||
if st.Code() == codes.NotFound {
|
if strings.Contains(cause.Error(), "not found") ||
|
||||||
|
strings.Contains(cause.Error(), "can't fetch container info") {
|
||||||
code = fasthttp.StatusNotFound
|
code = fasthttp.StatusNotFound
|
||||||
|
msg = errObjectNotFound.Error()
|
||||||
}
|
}
|
||||||
msg = st.Message()
|
|
||||||
}
|
|
||||||
r.Error(msg, code)
|
r.Error(msg, code)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue