Check whether variable is a WordPress Error.

Looks at the object and if a WP_Error class. Does not check to see if the parent is also WP_Error, so can’t inherit WP_Error and still use this function.

Signature

is_wp_error( $thing )
thing
 (mixed) Check if unknown variable is WordPress Error object.

Return

(boolean) True, if WP_Error. False, if not WP_Error.

Source

function is_wp_error($thing) {
	if ( is_object($thing) && is_a($thing, 'WP_Error') )
		return true;
	return false;
}
WP Trac GitHub Bitbucket

Link here