Automattic\WooCommerce\StoreApi\Routes\V1\Agentic
Error::to_rest_response
Convert the error to a WP_REST_Response.
Method of the class: Error{}
No Hooks.
Returns
WP_REST_Response. WordPress REST API response object
Usage
$Error = new Error(); $Error->to_rest_response();
Error::to_rest_response() Error::to rest response code WC 10.7.0
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 );
}