make the error handling idiomatic (#9942)

remove an excess if-else

* run gofmt
Этот коммит содержится в:
Mukul Rawat
2018-12-05 02:25:13 +05:30
коммит произвёл Jesús Espino
родитель b1438209a6
Коммит d3c55b8a02

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

@@ -209,15 +209,14 @@ func getPost(c *Context, w http.ResponseWriter, r *http.Request) {
return return
} }
var post *model.Post post, err := c.App.GetSinglePost(c.Params.PostId)
var err *model.AppError if err != nil {
if post, err = c.App.GetSinglePost(c.Params.PostId); err != nil {
c.Err = err c.Err = err
return return
} }
var channel *model.Channel channel, err := c.App.GetChannel(post.ChannelId)
if channel, err = c.App.GetChannel(post.ChannelId); err != nil { if err != nil {
c.Err = err c.Err = err
return return
} }
@@ -282,23 +281,20 @@ func getPostThread(c *Context, w http.ResponseWriter, r *http.Request) {
return return
} }
var list *model.PostList list, err := c.App.GetPostThread(c.Params.PostId)
var err *model.AppError if err != nil {
if list, err = c.App.GetPostThread(c.Params.PostId); err != nil {
c.Err = err c.Err = err
return return
} }
var post *model.Post post, ok := list.Posts[c.Params.PostId]
if val, ok := list.Posts[c.Params.PostId]; ok { if !ok {
post = val
} else {
c.SetInvalidUrlParam("post_id") c.SetInvalidUrlParam("post_id")
return return
} }
var channel *model.Channel channel, err := c.App.GetChannel(post.ChannelId)
if channel, err = c.App.GetChannel(post.ChannelId); err != nil { if err != nil {
c.Err = err c.Err = err
return return
} }