From 5d3a329a7a50f013a204f4d8134f62032c5ba6bd Mon Sep 17 00:00:00 2001 From: Matt Baer Date: Tue, 25 Sep 2018 12:24:51 -0400 Subject: [PATCH] Rearrange status checks in CreatePost --- post.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/post.go b/post.go index ac10fcc..4abda8e 100644 --- a/post.go +++ b/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