Automattic\WooCommerce\StoreApi\Exceptions

RouteException::__construct │ public │ WC 1.0

Setup exception.

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

Хуков нет.

Возвращает

null. Ничего (null).

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

$RouteException = new RouteException();
$RouteException->__construct( $error_code, $message, $http_status_code, $additional_data );
$error_code(строка) (обязательный)
Machine-readable error code, e.g woocommerce_invalid_product_id.
$message(строка) (обязательный)
User-friendly translated error message, e.g. 'Product ID is invalid'.
$http_status_code(int)
Proper HTTP status code to respond with, e.g. 400.
По умолчанию: 400
$additional_data(массив)
Extra data (key value pairs) to expose in the error response.
По умолчанию: []

Код RouteException::__construct() WC 11.2.2

public function __construct( $error_code, $message, $http_status_code = 400, $additional_data = [] ) {
	$this->error_code = $error_code;

	// Only drop values the client cannot act on. `0` and `false` are meaningful here (e.g. a confirmed total of zero).
	$this->additional_data = array_filter(
		(array) $additional_data,
		static function ( $value ) {
			return null !== $value && '' !== $value && [] !== $value;
		}
	);

	parent::__construct( $message, $http_status_code );
}