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:
parent
ca804e86e2
commit
5d3a329a7a
10
post.go
10
post.go
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user