error_to_response example

$result = $this->check_authentication();

        if ( ! is_wp_error( $result ) ) {
            $result = $this->dispatch( $request );
        }

        // Normalize to either WP_Error or WP_REST_Response...         $result = rest_ensure_response( $result );

        // ...then convert WP_Error across.         if ( is_wp_error( $result ) ) {
            $result = $this->error_to_response( $result );
        }

        /** * Filters the REST API response. * * Allows modification of the response before returning. * * @since 4.4.0 * @since 4.5.0 Applied to embedded responses. * * @param WP_HTTP_Response $result Result to send to the client. Usually a `WP_REST_Response`. * @param WP_REST_Server $server Server instance. * @param WP_REST_Request $request Request used to generate the response. */
Home | Imprint | This part of the site doesn't use cookies.