rest_convert_error_to_response ( $error )
- (WP_Error) error WP_Error instance.
- (WP_REST_Response) List of associative arrays with code and message keys.
- Introduced in WordPress: 5.7.0
- Deprecated in WordPress: —
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.