[#144] Add more verbose error output

Signed-off-by: Denis Kirillov <denis@nspcc.ru>
This commit is contained in:
Denis Kirillov 2022-04-20 13:03:06 +03:00 committed by Kira
parent 2884abafd0
commit 4f2b21a14b
2 changed files with 14 additions and 14 deletions

View file

@ -98,7 +98,7 @@ func (r request) receiveFile(clnt *pool.Pool, objectAddress *address.Address) {
)
if err = tokens.StoreBearerToken(r.RequestCtx); err != nil {
r.log.Error("could not fetch and store bearer token", zap.Error(err))
response.Error(r.RequestCtx, "could not fetch and store bearer token", fasthttp.StatusBadRequest)
response.Error(r.RequestCtx, "could not fetch and store bearer token: "+err.Error(), fasthttp.StatusBadRequest)
return
}
@ -162,7 +162,7 @@ func (r request) receiveFile(clnt *pool.Pool, objectAddress *address.Address) {
})
if err != nil && err != io.EOF {
r.log.Error("could not detect Content-Type from payload", zap.Error(err))
response.Error(r.RequestCtx, "could not detect Content-Type from payload", fasthttp.StatusBadRequest)
response.Error(r.RequestCtx, "could not detect Content-Type from payload: "+err.Error(), fasthttp.StatusBadRequest)
return
}
@ -316,7 +316,7 @@ func (d *Downloader) byAttribute(c *fasthttp.RequestCtx, f func(request, *pool.P
res, err := d.search(c, containerID, key, val, object.MatchStringEqual)
if err != nil {
log.Error("could not search for objects", zap.Error(err))
response.Error(c, "could not search for objects", fasthttp.StatusBadRequest)
response.Error(c, "could not search for objects: "+err.Error(), fasthttp.StatusBadRequest)
return
}
@ -333,7 +333,7 @@ func (d *Downloader) byAttribute(c *fasthttp.RequestCtx, f func(request, *pool.P
}
log.Error("read object list failed", zap.Error(err))
response.Error(c, "read object list failed", fasthttp.StatusBadRequest)
response.Error(c, "read object list failed: "+err.Error(), fasthttp.StatusBadRequest)
return
}
@ -372,14 +372,14 @@ func (d *Downloader) DownloadZipped(c *fasthttp.RequestCtx) {
if err := tokens.StoreBearerToken(c); err != nil {
log.Error("could not fetch and store bearer token", zap.Error(err))
response.Error(c, "could not fetch and store bearer token", fasthttp.StatusBadRequest)
response.Error(c, "could not fetch and store bearer token: "+err.Error(), fasthttp.StatusBadRequest)
return
}
resSearch, err := d.search(c, containerID, attributeFilePath, prefix, object.MatchCommonPrefix)
if err != nil {
log.Error("could not search for objects", zap.Error(err))
response.Error(c, "could not search for objects", fasthttp.StatusBadRequest)
response.Error(c, "could not search for objects: "+err.Error(), fasthttp.StatusBadRequest)
return
}
@ -457,7 +457,7 @@ func (d *Downloader) DownloadZipped(c *fasthttp.RequestCtx) {
})
if errIter != nil {
log.Error("iterating over selected objects failed", zap.Error(errIter))
response.Error(c, "iterating over selected objects", fasthttp.StatusBadRequest)
response.Error(c, "iterating over selected objects: "+errIter.Error(), fasthttp.StatusBadRequest)
return
} else if !called {
log.Error("objects not found")
@ -471,7 +471,7 @@ func (d *Downloader) DownloadZipped(c *fasthttp.RequestCtx) {
if err != nil {
log.Error("file streaming failure", zap.Error(err))
response.Error(c, "file streaming failure", fasthttp.StatusInternalServerError)
response.Error(c, "file streaming failure: "+err.Error(), fasthttp.StatusInternalServerError)
return
}
}

View file

@ -95,12 +95,12 @@ func (u *Uploader) Upload(c *fasthttp.RequestCtx) {
epochDuration, err := getEpochDurations(c, u.pool)
if err != nil {
log.Error("could not get epoch durations from network info", zap.Error(err))
response.Error(c, "could parse expiration header, try expiration in epoch", fasthttp.StatusBadRequest)
response.Error(c, "could not get epoch durations from network info: "+err.Error(), fasthttp.StatusBadRequest)
return
}
if err = prepareExpirationHeader(filtered, epochDuration); err != nil {
log.Error("could not prepare expiration header", zap.Error(err))
response.Error(c, "could parse expiration header, try expiration in epoch", fasthttp.StatusBadRequest)
log.Error("could not parse expiration header", zap.Error(err))
response.Error(c, "could not parse expiration header: "+err.Error(), fasthttp.StatusBadRequest)
return
}
}
@ -144,7 +144,7 @@ func (u *Uploader) Upload(c *fasthttp.RequestCtx) {
if idObj, err = u.pool.PutObject(ctx, prm); err != nil {
log.Error("could not store file in neofs", zap.Error(err))
response.Error(c, "could not store file in neofs", fasthttp.StatusBadRequest)
response.Error(c, "could not store file in neofs: "+err.Error(), fasthttp.StatusBadRequest)
return
}
@ -153,8 +153,8 @@ func (u *Uploader) Upload(c *fasthttp.RequestCtx) {
// Try to return the response, otherwise, if something went wrong, throw an error.
if err = newPutResponse(addr).encode(c); err != nil {
log.Error("could not prepare response", zap.Error(err))
response.Error(c, "could not prepare response", fasthttp.StatusBadRequest)
log.Error("could not encode response", zap.Error(err))
response.Error(c, "could not encode response", fasthttp.StatusBadRequest)
return
}