Automattic\WooCommerce\StoreApi\Routes\V1\Agentic

Error::to_rest_responsepublicWC 1.0

Convert the error to a WP_REST_Response.

Метод класса: Error{}

Хуков нет.

Возвращает

WP_REST_Response. WordPress REST API response object

Использование

$Error = new Error();
$Error->to_rest_response();

Код Error::to_rest_response() WC 11.0.1

public function to_rest_response() {
	$data = array(
		'type'    => $this->type,
		'code'    => $this->code,
		'message' => $this->message,
	);

	if ( null !== $this->param ) {
		$data['param'] = $this->param;
	}

	$status_code = $this->get_http_status_code();

	return new WP_REST_Response( $data, $status_code );
}