Description
Currently, there are two similar scenarios where a REST API request can fail:
- 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
- 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:
gutenberg/packages/api-fetch/src/index.js
Lines 54 to 60 in 186716f
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.