mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
make the error handling idiomatic (#9942)
remove an excess if-else * run gofmt
This commit is contained in:
committed by
Jesús Espino
parent
b1438209a6
commit
d3c55b8a02
24
api4/post.go
24
api4/post.go
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user