[MM-45991] Check and return JSON errors (#20735)
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
fdee1df6fe
Коммит
1738bd6e92
@@ -62,17 +62,18 @@ func getReactions(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
reactions, err := c.App.GetReactionsForPost(c.Params.PostId)
|
||||
if err != nil {
|
||||
c.Err = err
|
||||
reactions, appErr := c.App.GetReactionsForPost(c.Params.PostId)
|
||||
if appErr != nil {
|
||||
c.Err = appErr
|
||||
return
|
||||
}
|
||||
|
||||
js, jsonErr := json.Marshal(reactions)
|
||||
if jsonErr != nil {
|
||||
c.Err = model.NewAppError("getReactions", "api.marshal_error", nil, jsonErr.Error(), http.StatusInternalServerError)
|
||||
js, err := json.Marshal(reactions)
|
||||
if err != nil {
|
||||
c.Err = model.NewAppError("getReactions", "api.marshal_error", nil, "", http.StatusInternalServerError).Wrap(err)
|
||||
return
|
||||
}
|
||||
|
||||
w.Write(js)
|
||||
}
|
||||
|
||||
@@ -125,15 +126,15 @@ func getBulkReactions(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
}
|
||||
reactions, err := c.App.GetBulkReactionsForPosts(postIds)
|
||||
if err != nil {
|
||||
c.Err = err
|
||||
reactions, appErr := c.App.GetBulkReactionsForPosts(postIds)
|
||||
if appErr != nil {
|
||||
c.Err = appErr
|
||||
return
|
||||
}
|
||||
|
||||
js, jsonErr := json.Marshal(reactions)
|
||||
if jsonErr != nil {
|
||||
c.Err = model.NewAppError("getBulkReactions", "api.marshal_error", nil, jsonErr.Error(), http.StatusInternalServerError)
|
||||
js, err := json.Marshal(reactions)
|
||||
if err != nil {
|
||||
c.Err = model.NewAppError("getBulkReactions", "api.marshal_error", nil, "", http.StatusInternalServerError).Wrap(err)
|
||||
return
|
||||
}
|
||||
w.Write(js)
|
||||
|
||||
Ссылка в новой задаче
Block a user