Skip to content
This repository was archived by the owner on Aug 27, 2018. It is now read-only.
This repository was archived by the owner on Aug 27, 2018. It is now read-only.

Handle all the errors. #268

@kwight

Description

@kwight

Started by @dmsnell in https://github.com/Automattic/notifications-client/issues/170:

There are too many places where the following exist.

function( error, data ) {
    if ( error ) { throw error; return; }
}

All of these should probably do something or check something.

Known API Error Responses

Comment Endpoint

New comments/replies

  • 404 unknown comment - Unknown comment parent comment not found
  • 404 unknown post - Unknown post parent post not found
  • 403 unauthorized - User cannot create comments blog is not public and user is neither a member nor superadmin
  • 403 unauthorized - Comments on this post are closed
  • 403 unauthorized - User cannot view post
  • 403 unauthorized/private_blog - User cannot view post blog not public and no read_post permission for post
  • 403 unauthorized/password_protected - User cannot view password protected post password exists and no edit_post permission for post
  • 403 unauthorized - Comments on drafts are not allowed post status is neither public nor private
  • 400 invalid_input - Invalid request input no input or zero-length input
  • 403 authorization_required - An active access token must be used to comment.
  • 400 - Comment cache problem? newly inserted comment doesn't exist after inserting

Like/unlike

Approve/unapprove

Spam

Trash

Proper Behavior

Optimistic updating

In many places we update the UI to reflect changes we are requesting from the server, such as when liking a comment. The local client sets the like status and waits for a response from the API request to reload the affected note(s). When we have API requests that never succeed, the new note data is never called and thus the UI reflects the wrong state for those values. In these cases, we should undo the optimistic changes and reset the UI.

Retry attempts

Errors that are denials, such as unauthorized should never be resent. Sending the API request a second or third time will normally result in the same error. Instead, we should stop trying and indicate to the user that something happened, such as a message saying "Could not complete: comment not found".

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions