forked from TrueCloudLab/frostfs-rest-gw
[#15] Use extended error response
Signed-off-by: Denis Kirillov <denis@nspcc.ru>
This commit is contained in:
parent
e28c6e5375
commit
9fba8d7f23
22 changed files with 528 additions and 174 deletions
|
@ -11,6 +11,7 @@ import (
|
|||
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
|
||||
"github.com/nspcc-dev/neofs-rest-gw/gen/models"
|
||||
"github.com/nspcc-dev/neofs-rest-gw/gen/restapi/operations"
|
||||
"github.com/nspcc-dev/neofs-rest-gw/internal/util"
|
||||
"github.com/nspcc-dev/neofs-sdk-go/pool"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
@ -113,3 +114,9 @@ func (a *API) setupGlobalMiddleware(handler http.Handler) http.Handler {
|
|||
handler.ServeHTTP(w, r.WithContext(ctx))
|
||||
})
|
||||
}
|
||||
|
||||
func (a *API) logAndGetErrorResponse(msg string, err error, fields ...zap.Field) *models.ErrorResponse {
|
||||
fields = append(fields, zap.Error(err))
|
||||
a.log.Error(msg, fields...)
|
||||
return util.NewErrorResponse(fmt.Errorf("%s: %w", msg, err))
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue