WordPress / gutenberg

The Block Editor project for WordPress and beyond. Plugin is available from the official repository.
https://wordpress.org/gutenberg/
Other
10.51k stars 4.2k forks source link

Consider using REST API data for database errors. #64158

Open peterwilsoncc opened 3 months ago

peterwilsoncc commented 3 months ago

What problem does this address?

Currently saving errors in the database show the generic error message: Updating failed. Could not update post in the database.

Screenshot 2024-08-01 at 2 08 30 PM

While the message explains what happened, it provides no indication of how the user can fix it.

What is your proposed solution?

The REST API response includes further details about the field or fields that caused the error: WordPress database error: Processing the value for the following field failed: %s. The supplied value may be too long or contains invalid data.

{
    "code": "db_update_error",
    "message": "Could not update post in the database.",
    "data": {
        "status": 500
    },
    "additional_data": [
        "WordPress database error: Processing the value for the following field failed: post_password. The supplied value may be too long or contains invalid data."
    ]
}

Using the additional data could be helpful in providing users with an indication of why the database error occurred.

While the main portion of the content is translated, the field or fields that caused the error to occur are not (all sites use English for the database table names). So it's possible some work would need to be done to make the error messages more useful for non-English sites.

Props @ramonjd for the suggestion in #64155

hanneslsm commented 3 months ago

Yes please, that'd be a big UX improvement! Could potentially solve https://github.com/WordPress/gutenberg/issues/53095 and similar issues. We'd probably need to go through the copy in future but making it technically possible to provide more info would be a big win already.