Browse Source

Rearrange status checks in UpdatePost

pull/10/head
Matt Baer 5 years ago
parent
commit
2915667895
1 changed files with 8 additions and 7 deletions
  1. +8
    -7
      post.go

+ 8
- 7
post.go View File

@@ -148,14 +148,15 @@ func (c *Client) UpdatePost(sp *PostParams) (*Post, error) {
}

status := env.Code
if status == http.StatusOK {
return p, nil
} else if c.isNotLoggedIn(status) {
return nil, fmt.Errorf("Not authenticated.")
} else if status == http.StatusBadRequest {
return nil, fmt.Errorf("Bad request: %s", env.ErrorMessage)
if status != http.StatusOK {
if c.isNotLoggedIn(status) {
return nil, fmt.Errorf("Not authenticated.")
} else if status == http.StatusBadRequest {
return nil, fmt.Errorf("Bad request: %s", env.ErrorMessage)
}
return nil, fmt.Errorf("Problem getting post: %d. %v\n", status, err)
}
return nil, fmt.Errorf("Problem getting post: %d. %v\n", status, err)
return p, nil
}

// DeletePost permanently deletes a published post. See


Loading…
Cancel
Save