Skip to content

Present a more specific and descriptive error message when a REST API request fails #10492

Open

Description

Currently, there are two similar scenarios where a REST API request can fail:

  1. The REST API isn't enabled (because it's been disabled by a plugin, rewrites are missing, etc.). Originally Detect and show a notice when REST API is disabled #8549
  2. The server returned a malformed JSON response (because of PHP error notices, etc.). Originally Improve resilience to PHP Notices and Warnings #4936

In both of these cases, Gutenberg receives a response but is unable to deserialize it. As a result, the end user sees a generic 'Updating failed.' error message.

While hopefully many of these failures will be addressed with #10476, it would be ideal if Gutenberg presented the end user a more specific and descriptive error message.

@aduth identified (#4936 (comment)) the following as a possible place we could interpret failed responses:

const parseResponse = ( response ) => {
if ( parse ) {
return response.json ? response.json() : Promise.reject( response );
}
return response;
};

In order to resolve this issue, we'd need to catch the two scenarios listed above, and display a more specific and descriptive error message accordingly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions