forked from TrueCloudLab/frostfs-http-gw
[#18] Extract error details
Signed-off-by: Denis Kirillov <d.kirillov@yadro.com>
This commit is contained in:
parent
e02ee50d7b
commit
8f6be59e23
4 changed files with 50 additions and 12 deletions
|
@ -182,8 +182,7 @@ func (u *Uploader) Upload(c *fasthttp.RequestCtx) {
|
|||
}
|
||||
|
||||
if idObj, err = u.pool.PutObject(u.appCtx, prm); err != nil {
|
||||
log.Error("could not store file in frostfs", zap.Error(err))
|
||||
response.Error(c, "could not store file in frostfs: "+err.Error(), fasthttp.StatusBadRequest)
|
||||
u.handlePutFrostFSErr(c, err)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -214,6 +213,14 @@ func (u *Uploader) Upload(c *fasthttp.RequestCtx) {
|
|||
c.Response.Header.SetContentType(jsonHeader)
|
||||
}
|
||||
|
||||
func (u *Uploader) handlePutFrostFSErr(r *fasthttp.RequestCtx, err error) {
|
||||
statusCode, msg, additionalFields := response.FormErrorResponse("could not store file in frostfs", err)
|
||||
logFields := append([]zap.Field{zap.Error(err)}, additionalFields...)
|
||||
|
||||
u.log.Error("could not store file in frostfs", logFields...)
|
||||
response.Error(r, msg, statusCode)
|
||||
}
|
||||
|
||||
func (u *Uploader) fetchOwnerAndBearerToken(ctx context.Context) (*user.ID, *bearer.Token) {
|
||||
if tkn, err := tokens.LoadBearerToken(ctx); err == nil && tkn != nil {
|
||||
issuer := bearer.ResolveIssuer(*tkn)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue