Browse Source

Merge pull request #6 from ProfessorTom/fix_error_format_verbs

use correct verb for error formatting
tags/v1
Matt Baer 5 years ago
committed by GitHub
parent
commit
159315bfd1
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 9 deletions
  1. +1
    -1
      auth.go
  2. +3
    -3
      collection.go
  3. +5
    -5
      post.go

+ 1
- 1
auth.go View File

@@ -39,7 +39,7 @@ func (c *Client) LogIn(username, pass string) (*AuthUser, error) {
} else if status == http.StatusTooManyRequests {
return nil, fmt.Errorf("Stop repeatedly trying to log in.")
}
return nil, fmt.Errorf("Problem authenticating: %s. %v\n", status, err)
return nil, fmt.Errorf("Problem authenticating: %d. %v\n", status, err)
}

func (c *Client) isNotLoggedIn(code int) bool {


+ 3
- 3
collection.go View File

@@ -57,7 +57,7 @@ func (c *Client) CreateCollection(sp *CollectionParams) (*Collection, error) {
} else if status == http.StatusPreconditionFailed {
return nil, fmt.Errorf("Reached max collection quota.")
}
return nil, fmt.Errorf("Problem getting post: %s. %v\n", status, err)
return nil, fmt.Errorf("Problem getting post: %d. %v\n", status, err)
}

// GetCollection retrieves a collection, returning the Collection and any error
@@ -81,7 +81,7 @@ func (c *Client) GetCollection(alias string) (*Collection, error) {
} else if status == http.StatusNotFound {
return nil, fmt.Errorf("Collection not found.")
} else {
return nil, fmt.Errorf("Problem getting collection: %s. %v\n", status, err)
return nil, fmt.Errorf("Problem getting collection: %d. %v\n", status, err)
}
return coll, nil
}
@@ -107,7 +107,7 @@ func (c *Client) GetCollectionPosts(alias string) (*[]Post, error) {
} else if status == http.StatusNotFound {
return nil, fmt.Errorf("Collection not found.")
} else {
return nil, fmt.Errorf("Problem getting collection: %s. %v\n", status, err)
return nil, fmt.Errorf("Problem getting collection: %d. %v\n", status, err)
}
return coll.Posts, nil
}

+ 5
- 5
post.go View File

@@ -86,7 +86,7 @@ func (c *Client) GetPost(id string) (*Post, error) {
} else if status == http.StatusGone {
return nil, fmt.Errorf("Post unpublished.")
}
return nil, fmt.Errorf("Problem getting post: %s. %v\n", status, err)
return nil, fmt.Errorf("Problem getting post: %d. %v\n", status, err)
}

// CreatePost publishes a new post, returning a user-friendly error if one comes
@@ -113,7 +113,7 @@ func (c *Client) CreatePost(sp *PostParams) (*Post, error) {
} else if status == http.StatusBadRequest {
return nil, fmt.Errorf("Bad request: %s", env.ErrorMessage)
} else {
return nil, fmt.Errorf("Problem getting post: %s. %v\n", status, err)
return nil, fmt.Errorf("Problem getting post: %d. %v\n", status, err)
}
return p, nil
}
@@ -140,7 +140,7 @@ func (c *Client) UpdatePost(sp *PostParams) (*Post, error) {
} else if status == http.StatusBadRequest {
return nil, fmt.Errorf("Bad request: %s", env.ErrorMessage)
}
return nil, fmt.Errorf("Problem getting post: %s. %v\n", status, err)
return nil, fmt.Errorf("Problem getting post: %d. %v\n", status, err)
}

// DeletePost permanently deletes a published post. See
@@ -161,7 +161,7 @@ func (c *Client) DeletePost(sp *PostParams) error {
} else if status == http.StatusBadRequest {
return fmt.Errorf("Bad request: %s", env.ErrorMessage)
}
return fmt.Errorf("Problem getting post: %s. %v\n", status, err)
return fmt.Errorf("Problem getting post: %d. %v\n", status, err)
}

// ClaimPosts associates anonymous posts with a user / account.
@@ -186,7 +186,7 @@ func (c *Client) ClaimPosts(sp *[]OwnedPostParams) (*[]ClaimPostResult, error) {
} else if status == http.StatusBadRequest {
return nil, fmt.Errorf("Bad request: %s", env.ErrorMessage)
} else {
return nil, fmt.Errorf("Problem getting post: %s. %v\n", status, err)
return nil, fmt.Errorf("Problem getting post: %d. %v\n", status, err)
}
// TODO: does this also happen with moving posts?
return p, nil


Loading…
Cancel
Save