WP_REST_Response::is_error()publicWP 4.4.0

Checks if the response is an error, i.e. >= 400 response code.

Method of the class: WP_REST_Response{}

No Hooks.

Return

true|false. Whether the response is an error.

Usage

$WP_REST_Response = new WP_REST_Response();
$WP_REST_Response->is_error();

Changelog

Since 4.4.0 Introduced.

WP_REST_Response::is_error() code WP 6.5.2

public function is_error() {
	return $this->get_status() >= 400;
}