Codex

Function Reference/WP Error

Contents

About: Role of WP_Error

Instroduced with WordPress 2.1, WP_Error is a class that makes error handling within plugins and WordPress itself much easier.

Instances of WP_Error store error codes and messages representing one or more errors, and whether or not a variable is an instance of WP_Error can be determined using the is_wp_error() function.

Code

You may find the class WP_Error in your file /wp-includes/classes.php at line 299 and function is_wp_error() at line 377. You can also view this file online at the trac.

Methods and Properties

Properties

Methods

Example

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();


External Links

This page is marked as incomplete. You can help Codex by expanding it.