1
0
mirror of https://github.com/writeas/go-writeas.git synced 2025-07-27 15:18:28 +00:00

Rearrange status checks in CreatePost

This commit is contained in:
Matt Baer 2018-09-25 12:24:51 -04:00
parent ca804e86e2
commit 5d3a329a7a

10
post.go
View File

@ -124,13 +124,13 @@ func (c *Client) CreatePost(sp *PostParams) (*Post, error) {
}
status := env.Code
if status == http.StatusCreated {
return p, nil
} else if status == http.StatusBadRequest {
return nil, fmt.Errorf("Bad request: %s", env.ErrorMessage)
} else {
if status != http.StatusCreated {
if status == http.StatusBadRequest {
return nil, fmt.Errorf("Bad request: %s", env.ErrorMessage)
}
return nil, fmt.Errorf("Problem creating post: %d. %v\n", status, err)
}
return p, nil
}
// UpdatePost updates a published post with the given PostParams. See