rest_convert_error_to_response
rest_convert_error_to_response ( $error )
Parameters:- (WP_Error) error WP_Error instance.
Returns:- (WP_REST_Response) List of associative arrays with code and message keys.
Defined at: - Introduced in WordPress: 5.7.0
- Deprecated in WordPress: —
Description
Converts an error to a response object.This iterates over all error codes and messages to change it into a flat
array. This enables simpler client behavior, as it is represented as a
list in JSON rather than an object/map.