@@ -38,10 +38,8 @@ func (c *Client) LogIn(username, pass string) (*AuthUser, error) { | |||||
return nil, fmt.Errorf("User does not exist.") | return nil, fmt.Errorf("User does not exist.") | ||||
} else if status == http.StatusTooManyRequests { | } else if status == http.StatusTooManyRequests { | ||||
return nil, fmt.Errorf("Stop repeatedly trying to log in.") | return nil, fmt.Errorf("Stop repeatedly trying to log in.") | ||||
} else { | |||||
return nil, fmt.Errorf("Problem authenticating: %s. %v\n", status, err) | |||||
} | } | ||||
return u, nil | |||||
return nil, fmt.Errorf("Problem authenticating: %s. %v\n", status, err) | |||||
} | } | ||||
func (c *Client) isNotLoggedIn(code int) bool { | func (c *Client) isNotLoggedIn(code int) bool { | ||||
@@ -80,8 +80,6 @@ func (c *Client) CreateCollection(sp *CollectionParams) (*Collection, error) { | |||||
return nil, fmt.Errorf("Collection name is already taken.") | return nil, fmt.Errorf("Collection name is already taken.") | ||||
} else if status == http.StatusPreconditionFailed { | } else if status == http.StatusPreconditionFailed { | ||||
return nil, fmt.Errorf("Reached max collection quota.") | return nil, fmt.Errorf("Reached max collection quota.") | ||||
} else { | |||||
return nil, fmt.Errorf("Problem getting post: %s. %v\n", status, err) | |||||
} | } | ||||
return p, nil | |||||
return nil, fmt.Errorf("Problem getting post: %s. %v\n", status, err) | |||||
} | } |
@@ -81,10 +81,8 @@ func (c *Client) GetPost(id string) (*Post, error) { | |||||
return nil, fmt.Errorf("Post not found.") | return nil, fmt.Errorf("Post not found.") | ||||
} else if status == http.StatusGone { | } else if status == http.StatusGone { | ||||
return nil, fmt.Errorf("Post unpublished.") | return nil, fmt.Errorf("Post unpublished.") | ||||
} else { | |||||
return nil, fmt.Errorf("Problem getting post: %s. %v\n", status, err) | |||||
} | } | ||||
return p, nil | |||||
return nil, fmt.Errorf("Problem getting post: %s. %v\n", status, err) | |||||
} | } | ||||
// CreatePost publishes a new post, returning a user-friendly error if one comes | // CreatePost publishes a new post, returning a user-friendly error if one comes | ||||
@@ -133,10 +131,8 @@ func (c *Client) UpdatePost(sp *PostParams) (*Post, error) { | |||||
return nil, fmt.Errorf("Not authenticated.") | return nil, fmt.Errorf("Not authenticated.") | ||||
} else if status == http.StatusBadRequest { | } else if status == http.StatusBadRequest { | ||||
return nil, fmt.Errorf("Bad request: %s", env.ErrorMessage) | return nil, fmt.Errorf("Bad request: %s", env.ErrorMessage) | ||||
} else { | |||||
return nil, fmt.Errorf("Problem getting post: %s. %v\n", status, err) | |||||
} | } | ||||
return p, nil | |||||
return nil, fmt.Errorf("Problem getting post: %s. %v\n", status, err) | |||||
} | } | ||||
// DeletePost permanently deletes a published post. See | // DeletePost permanently deletes a published post. See | ||||