[MM-45990] log JSON parsing errors in API4 (#20724)
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
04cd6d35e9
Коммит
832736da37
16
api4/bot.go
16
api4/bot.go
@@ -28,7 +28,7 @@ func createBot(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
var botPatch *model.BotPatch
|
||||
err := json.NewDecoder(r.Body).Decode(&botPatch)
|
||||
if err != nil {
|
||||
c.SetInvalidParam("bot")
|
||||
c.SetInvalidParamWithErr("bot", err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ func createBot(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
w.WriteHeader(http.StatusCreated)
|
||||
if err := json.NewEncoder(w).Encode(createdBot); err != nil {
|
||||
mlog.Warn("Error while writing response", mlog.Err(err))
|
||||
c.Logger.Warn("Error while writing response", mlog.Err(err))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@ func patchBot(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
var botPatch *model.BotPatch
|
||||
err := json.NewDecoder(r.Body).Decode(&botPatch)
|
||||
if err != nil {
|
||||
c.SetInvalidParam("bot")
|
||||
c.SetInvalidParamWithErr("bot", err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -109,7 +109,7 @@ func patchBot(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
auditRec.AddEventObjectType("bot")
|
||||
|
||||
if err := json.NewEncoder(w).Encode(updatedBot); err != nil {
|
||||
mlog.Warn("Error while writing response", mlog.Err(err))
|
||||
c.Logger.Warn("Error while writing response", mlog.Err(err))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -150,7 +150,7 @@ func getBot(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
if err := json.NewEncoder(w).Encode(bot); err != nil {
|
||||
mlog.Warn("Error while writing response", mlog.Err(err))
|
||||
c.Logger.Warn("Error while writing response", mlog.Err(err))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -268,7 +268,7 @@ func assignBot(c *Context, w http.ResponseWriter, _ *http.Request) {
|
||||
auditRec.AddEventObjectType("bot")
|
||||
|
||||
if err := json.NewEncoder(w).Encode(bot); err != nil {
|
||||
mlog.Warn("Error while writing response", mlog.Err(err))
|
||||
c.Logger.Warn("Error while writing response", mlog.Err(err))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -287,7 +287,7 @@ func convertBotToUser(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
var userPatch model.UserPatch
|
||||
jsonErr := json.NewDecoder(r.Body).Decode(&userPatch)
|
||||
if jsonErr != nil || userPatch.Password == nil || *userPatch.Password == "" {
|
||||
c.SetInvalidParam("userPatch")
|
||||
c.SetInvalidParamWithErr("userPatch", jsonErr)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -315,6 +315,6 @@ func convertBotToUser(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
auditRec.AddEventObjectType("user")
|
||||
|
||||
if err := json.NewEncoder(w).Encode(user); err != nil {
|
||||
mlog.Warn("Error while writing response", mlog.Err(err))
|
||||
c.Logger.Warn("Error while writing response", mlog.Err(err))
|
||||
}
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user