Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve error messages for clarity #8177

Open
wants to merge 3 commits into
base: trunk
Choose a base branch
from

Conversation

Sukhendu2002
Copy link

Trac ticket: https://core.trac.wordpress.org/ticket/43622


This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.

Copy link

Test using WordPress Playground

The changes in this pull request can previewed and tested using a WordPress Playground instance.

WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser.

Some things to be aware of

  • The Plugin and Theme Directories cannot be accessed within Playground.
  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

@joedolson joedolson self-requested a review January 23, 2025 21:55
@Sukhendu2002 Sukhendu2002 marked this pull request as ready for review January 24, 2025 06:32
Copy link

github-actions bot commented Jan 24, 2025

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Core Committers: Use this line as a base for the props when committing in SVN:

Props sukhendu2002, joedolson.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

Copy link
Contributor

@joedolson joedolson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some structural changes, but also some things that could be more appropriate to the WordPress context.

@@ -76,7 +76,7 @@

if ( in_array( get_post_status( $changeset_post->ID ), array( 'publish', 'trash' ), true ) ) {
wp_die(
'<h1>' . __( 'Something went wrong.' ) . '</h1>' .
'<h1>' . __( 'An error occurred while saving your changeset. Please try again or start a new changeset.' ) . '</h1>' .
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keep headings short - no more than one sentence, then add additional context as paragraphs below.

The heading should probably be "An error occurred while saving your changeset."

@@ -830,7 +830,7 @@ public function step_2() {

if ( ! current_theme_supports( 'custom-header', 'uploads' ) ) {
wp_die(
'<h1>' . __( 'Something went wrong.' ) . '</h1>' .
'<h1>' . __( 'An error occurred while processing your header image. Please ensure your theme supports custom headers and try again.' ) . '</h1>' .
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As above, just use the first sentence as the heading, then add additional context in paragraphs below.

@@ -1018,7 +1018,7 @@ public function step_3() {

if ( ! current_theme_supports( 'custom-header', 'uploads' ) ) {
wp_die(
'<h1>' . __( 'Something went wrong.' ) . '</h1>' .
'<h1>' . __( 'An error occurred while processing your header image. Please ensure your theme supports custom headers and try again.' ) . '</h1>' .
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same issue; use first sentence as heading, move second sentence to a paragraph below.

@@ -1029,7 +1029,7 @@ public function step_3() {
&& ! current_theme_supports( 'custom-header', 'flex-width' )
) {
wp_die(
'<h1>' . __( 'Something went wrong.' ) . '</h1>' .
'<h1>' . __( 'An error occurred while processing your header image. Please ensure your theme supports custom headers and try again.' ) . '</h1>' .
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same issue; use first sentence as heading, move second sentence to a paragraph below.

@@ -35,7 +35,7 @@
// Require an ID for the edit screen.
if ( isset( $action ) && 'edit' === $action && ! $ID ) { // phpcs:ignore WordPress.NamingConventions.ValidVariableName
wp_die(
'<h1>' . __( 'Something went wrong.' ) . '</h1>' .
'<h1>' . __( 'An error occurred during the upload process. Please try again or contact support.' ) . '</h1>' .
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no support to contact, and this error doesn't really give enough context for anybody to get a lot of value out of it by taking it to the support forums. I think eliminate 'or contact support', and move the additional sentence into the next paragraph.

@@ -155,7 +155,7 @@
// If the user doesn't already belong to the blog, bail.
if ( is_multisite() && ! is_user_member_of_blog( $id ) ) {
wp_die(
'<h1>' . __( 'Something went wrong.' ) . '</h1>' .
'<h1>' . __( 'An unexpected error occurred. Please try again or contact support.' ) . '</h1>' .
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the second sentence here.

@@ -5040,7 +5040,7 @@ public function blogger_getRecentPosts( $args ) {
$posts_list = wp_get_recent_posts( $query );

if ( ! $posts_list ) {
$this->error = new IXR_Error( 500, __( 'Either there are no posts, or something went wrong.' ) );
$this->error = new IXR_Error( 500, __( 'No posts found or an error occurred while retrieving posts. Please try again later.' ) );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think "please try again later" is appropriate here; that implies that this is known to be a temporary error, and we don't actually know that at this stage.

@@ -6523,7 +6523,7 @@ public function mt_getRecentPostTitles( $args ) {
$posts_list = wp_get_recent_posts( $query );

if ( ! $posts_list ) {
$this->error = new IXR_Error( 500, __( 'Either there are no posts, or something went wrong.' ) );
$this->error = new IXR_Error( 500, __( 'No posts found or an error occurred while retrieving posts. Please try again later.' ) );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove "Please try again later."

@@ -810,7 +810,7 @@ function wp_default_scripts( $scripts ) {
'wpAjax',
array(
'noPerm' => __( 'Sorry, you are not allowed to do that.' ),
'broken' => __( 'Something went wrong.' ),
'broken' => __( 'An unexpected error occurred while processing your request. Please try again later or contact support if the issue persists.' ),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove "or contact support if the issue persists."

@@ -1292,7 +1292,7 @@ function wp_default_scripts( $scripts ) {
'close' => __( 'Close' ),
'action' => __( 'Action' ),
'discardChanges' => __( 'Discard changes' ),
'cheatin' => __( 'Something went wrong.' ),
'cheatin' => __( 'An unexpected error occurred. Please check your permissions and try again.' ),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Permissions are not the only situation that can trigger 'cheatin', so that should probably not be implied. It's mostly about invalid nonce values.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants