Automattic / notifications-panel

Core notifications panel for WordPress.com notifications
0 stars 1 forks source link

Handle all the errors. #268

Open kwight opened 6 years ago

kwight commented 6 years ago

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

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".