WC_REST_WCCOM_Site_Installer_Controller::failure_response
Generate a standardized response for a failed request.
Method of the class: WC_REST_WCCOM_Site_Installer_Controller{}
No Hooks.
Returns
WP_REST_Response|WP_Error.
Usage
// protected - for code of main (parent) or child class $result = $this->failure_response( $product_id, $exception );
- $product_id(int) (required)
- Product ID.
- $exception(Installer_Error) (required)
- The exception.
WC_REST_WCCOM_Site_Installer_Controller::failure_response() WC REST WCCOM Site Installer Controller::failure response code WC 10.3.3
woocommerce/includes/wccom-site/rest-api/endpoints/class-wc-rest-wccom-site-installer-controller.php
protected function failure_response( $product_id, $exception ) {
$state = WC_WCCOM_Site_Installation_State_Storage::get_state( $product_id );
$response = rest_ensure_response(
array(
'success' => false,
'error_code' => $exception->get_error_code(),
'error_message' => $exception->get_error_message(),
'state' => $state ? $this->map_state_to_response( $state ) : null,
)
);
$response->set_status( $exception->get_http_code() );
return $response;
}