Automattic\WooCommerce\StoreApi\Schemas

ExtendSchema::throw_exception()privateWC 1.0

Throws error and/or silently logs it.

Method of the class: ExtendSchema{}

No Hooks.

Return

null. Nothing (null).

Usage

// private - for code of main (parent) class only
$result = $this->throw_exception( $exception_or_error );
$exception_or_error(string|\Throwable) (required)
Error message or \Exception.

ExtendSchema::throw_exception() code WC 8.7.0

private function throw_exception( $exception_or_error ) {
	$exception = is_string( $exception_or_error ) ? new \Exception( $exception_or_error ) : $exception_or_error;

	wc_caught_exception( $exception );

	if ( defined( 'WP_DEBUG' ) && WP_DEBUG && current_user_can( 'manage_woocommerce' ) ) {
		throw $exception;
	}
}