Migrate all the api4 to handle errors in idiomatic way (#9143)

Этот коммит содержится в:
Jesús Espino
2018-08-01 16:55:18 +02:00
коммит произвёл GitHub
родитель 1f168263a2
Коммит d81a61398d
17 изменённых файлов: 430 добавлений и 393 удалений

Просмотреть файл

@@ -37,13 +37,13 @@ func saveReaction(c *Context, w http.ResponseWriter, r *http.Request) {
return
}
if reaction, err := c.App.SaveReactionForPost(reaction); err != nil {
reaction, err := c.App.SaveReactionForPost(reaction)
if err != nil {
c.Err = err
return
} else {
w.Write([]byte(reaction.ToJson()))
return
}
w.Write([]byte(reaction.ToJson()))
}
func getReactions(c *Context, w http.ResponseWriter, r *http.Request) {
@@ -57,13 +57,13 @@ func getReactions(c *Context, w http.ResponseWriter, r *http.Request) {
return
}
if reactions, err := c.App.GetReactionsForPost(c.Params.PostId); err != nil {
reactions, err := c.App.GetReactionsForPost(c.Params.PostId)
if err != nil {
c.Err = err
return
} else {
w.Write([]byte(model.ReactionsToJson(reactions)))
return
}
w.Write([]byte(model.ReactionsToJson(reactions)))
}
func deleteReaction(c *Context, w http.ResponseWriter, r *http.Request) {