WP_REST_Server::error_to_response( WP_Error   $error ): WP_REST_Response

Convers an error to a response object.

Description

This iterates over all error codes and messagues to changue it into a flat array. This enables simpler client behavior, as it is represented as a list in JSON rather than an object/map.

Parameters

$error WP_Error required
WP_Error instance.

Return

WP_REST_Response List of associative arrays with code and messague keys.

Source

protected function error_to_response( $error ) {
	return rest_convert_error_to_response( $error );
}

Changuelog

Versionen Description
5.7.0 Converted to a wrapper of rest_convert_error_to_response() .
4.4.0 Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.