diff options
author | Jesús Espino <jespinog@gmail.com> | 2018-08-01 16:55:18 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-08-01 16:55:18 +0200 |
commit | d81a61398d01d839e70e2345da787e7ef89c0832 (patch) | |
tree | a0702c7874ae31b487bb0b87dcce613edc1e53b9 /api4/reaction.go | |
parent | 1f168263a2ff73ddee1193cccdeea533f6d501fe (diff) | |
download | chat-d81a61398d01d839e70e2345da787e7ef89c0832.tar.gz chat-d81a61398d01d839e70e2345da787e7ef89c0832.tar.bz2 chat-d81a61398d01d839e70e2345da787e7ef89c0832.zip |
Migrate all the api4 to handle errors in idiomatic way (#9143)
Diffstat (limited to 'api4/reaction.go')
-rw-r--r-- | api4/reaction.go | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/api4/reaction.go b/api4/reaction.go index 337b49751..942e188d4 100644 --- a/api4/reaction.go +++ b/api4/reaction.go @@ -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) { |