WC_API_Exception::__construct()publicWC 2.2

Setup exception, requires 3 params:

error code - machine-readable, e.g. woocommerce_invalid_product_id error message - friendly message, e.g. 'Product ID is invalid' http status code - proper HTTP status code to respond with, e.g. 400

Method of the class: WC_API_Exception{}

No Hooks.

Return

null. Nothing (null).

Usage

$WC_API_Exception = new WC_API_Exception();
$WC_API_Exception->__construct( $error_code, $error_message, $http_status_code );
$error_code(string) (required)
-
$error_message(string) (required)
user-friendly translated error message
$http_status_code(int) (required)
HTTP status code to respond with

Changelog

Since 2.2 Introduced.

WC_API_Exception::__construct() code WC 8.7.0

public function __construct( $error_code, $error_message, $http_status_code ) {
	$this->error_code = $error_code;
	parent::__construct( $error_message, $http_status_code );
}