make the error handling idiomatic (#9942)

remove an excess if-else

* run gofmt
This commit is contained in:
Mukul Rawat
2018-12-05 02:25:13 +05:30
committed by Jesús Espino
parent b1438209a6
commit d3c55b8a02

View File

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