Make WordPress Core

Opened 18 years ago

Closed 18 years ago

#2600 closed defect (bug) (fixed)

WP_Error class for returning errors

Reported by: ryan's profile ryan Owned by: ryan's profile ryan
Milestone: 2.1 Priority: normal
Severity: normal Version: 2.1
Component: Administration Keywords: error
Focuses: Cc:


I'd like a nicer way to return errors, especially when validating forms and returning multiple error messages. Let's have a WP_Error class that holds error codes and messages. An is_wp_error function checks return values to see if they are a WP_Error.

function doer_of_stuff() {
  return  new WP_Error('broke', __("I've fallen and can't get up"));

$return = doer_of_stuff();
if ( is_wp_error($return) )
   echo $return->get_error_message();

Attachments (1)

wp_error.diff (1.2 KB) - added by ryan 18 years ago.
WP_Error and is_wp_error()

Download all attachments as: .zip

Change History (2)

18 years ago

WP_Error and is_wp_error()

#1 @ryan
18 years ago

  • Resolution set to fixed
  • Status changed from new to closed

(In [3667]) WP_Error. fixes #2600

Note: See TracTickets for help on using tickets.