forked from TrueCloudLab/frostfs-http-gw
[#144] Add more verbose error output
Signed-off-by: Denis Kirillov <denis@nspcc.ru>
This commit is contained in:
parent
2884abafd0
commit
4f2b21a14b
2 changed files with 14 additions and 14 deletions
|
@ -98,7 +98,7 @@ func (r request) receiveFile(clnt *pool.Pool, objectAddress *address.Address) {
|
||||||
)
|
)
|
||||||
if err = tokens.StoreBearerToken(r.RequestCtx); err != nil {
|
if err = tokens.StoreBearerToken(r.RequestCtx); err != nil {
|
||||||
r.log.Error("could not fetch and store bearer token", zap.Error(err))
|
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
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -162,7 +162,7 @@ func (r request) receiveFile(clnt *pool.Pool, objectAddress *address.Address) {
|
||||||
})
|
})
|
||||||
if err != nil && err != io.EOF {
|
if err != nil && err != io.EOF {
|
||||||
r.log.Error("could not detect Content-Type from payload", zap.Error(err))
|
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
|
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)
|
res, err := d.search(c, containerID, key, val, object.MatchStringEqual)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("could not search for objects", zap.Error(err))
|
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
|
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))
|
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
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -372,14 +372,14 @@ func (d *Downloader) DownloadZipped(c *fasthttp.RequestCtx) {
|
||||||
|
|
||||||
if err := tokens.StoreBearerToken(c); err != nil {
|
if err := tokens.StoreBearerToken(c); err != nil {
|
||||||
log.Error("could not fetch and store bearer token", zap.Error(err))
|
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
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
resSearch, err := d.search(c, containerID, attributeFilePath, prefix, object.MatchCommonPrefix)
|
resSearch, err := d.search(c, containerID, attributeFilePath, prefix, object.MatchCommonPrefix)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("could not search for objects", zap.Error(err))
|
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
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -457,7 +457,7 @@ func (d *Downloader) DownloadZipped(c *fasthttp.RequestCtx) {
|
||||||
})
|
})
|
||||||
if errIter != nil {
|
if errIter != nil {
|
||||||
log.Error("iterating over selected objects failed", zap.Error(errIter))
|
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
|
return
|
||||||
} else if !called {
|
} else if !called {
|
||||||
log.Error("objects not found")
|
log.Error("objects not found")
|
||||||
|
@ -471,7 +471,7 @@ func (d *Downloader) DownloadZipped(c *fasthttp.RequestCtx) {
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("file streaming failure", zap.Error(err))
|
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
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -95,12 +95,12 @@ func (u *Uploader) Upload(c *fasthttp.RequestCtx) {
|
||||||
epochDuration, err := getEpochDurations(c, u.pool)
|
epochDuration, err := getEpochDurations(c, u.pool)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("could not get epoch durations from network info", zap.Error(err))
|
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
|
return
|
||||||
}
|
}
|
||||||
if err = prepareExpirationHeader(filtered, epochDuration); err != nil {
|
if err = prepareExpirationHeader(filtered, epochDuration); err != nil {
|
||||||
log.Error("could not prepare expiration header", zap.Error(err))
|
log.Error("could not parse expiration header", zap.Error(err))
|
||||||
response.Error(c, "could parse expiration header, try expiration in epoch", fasthttp.StatusBadRequest)
|
response.Error(c, "could not parse expiration header: "+err.Error(), fasthttp.StatusBadRequest)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -144,7 +144,7 @@ func (u *Uploader) Upload(c *fasthttp.RequestCtx) {
|
||||||
|
|
||||||
if idObj, err = u.pool.PutObject(ctx, prm); err != nil {
|
if idObj, err = u.pool.PutObject(ctx, prm); err != nil {
|
||||||
log.Error("could not store file in neofs", zap.Error(err))
|
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
|
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.
|
// Try to return the response, otherwise, if something went wrong, throw an error.
|
||||||
if err = newPutResponse(addr).encode(c); err != nil {
|
if err = newPutResponse(addr).encode(c); err != nil {
|
||||||
log.Error("could not prepare response", zap.Error(err))
|
log.Error("could not encode response", zap.Error(err))
|
||||||
response.Error(c, "could not prepare response", fasthttp.StatusBadRequest)
|
response.Error(c, "could not encode response", fasthttp.StatusBadRequest)
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue