Make WordPress Core

Opened 6 years ago

Closed 6 years ago

#41237 closed feature request (maybelater)

All error messages including core at one place

Reported by: navalkishoregr's profile navalkishoregr Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: General Keywords:
Focuses: Cc:

Description

Why can't we manage all error messages at one place. Suppose we need any custom messages for rest apis and websites combining both is a headache.

Change History (5)

#1 @swissspidy
6 years ago

  • Component changed from Customize to General
  • Focuses rest-api performance removed

Can you perhaps elaborate a bit more on which error messages you mean?

Is the problem that you need to write them multiple times for different areas instead of being able to refer to a common error message?

#2 follow-up: @jnylen0
6 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to maybelater
  • Status changed from new to closed
  • Version 4.8 deleted

There is nothing stopping you from doing this in a plugin. For example:

<?php

function myplugin_get_error( $code ) {
    switch ( $code ) {
        case 'not_allowed':
            return new WP_Error( 'not_allowed', __( 'This operation is not allowed.', 'myplugin' ) );
        case 'not_implemented':
            return new WP_Error( 'not_implemented', __( 'This operation is not implemented yet.', 'myplugin' ) );
    }
}

It's possible that a pattern like this would also be a good fit for parts of core.

#3 in reply to: ↑ 2 @navalkishoregr
6 years ago

  • Resolution maybelater deleted
  • Status changed from closed to reopened

But what is the hook to add this function. Just if we write add this function will we be able to get all errors that are generating.

Replying to jnylen0:

There is nothing stopping you from doing this in a plugin. For example:

<?php

function myplugin_get_error( $code ) {
    switch ( $code ) {
        case 'not_allowed':
            return new WP_Error( 'not_allowed', __( 'This operation is not allowed.', 'myplugin' ) );
        case 'not_implemented':
            return new WP_Error( 'not_implemented', __( 'This operation is not implemented yet.', 'myplugin' ) );
    }
}

It's possible that a pattern like this would also be a good fit for parts of core.

#4 @SergeyBiryukov
6 years ago

  • Milestone set to Awaiting Review

#5 @jnylen0
6 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to maybelater
  • Status changed from reopened to closed

This is not something that exists today in WordPress core, and it is unlikely to be worked on soon. I am closing this ticket again, please feel free to leave comments but do not reopen it.

There is nothing stopping you from structuring a plugin or theme this way.

Note: See TracTickets for help on using tickets.