wc_caught_exception() │ WC 3.3.0

When catching an exception, this allows us to log it if unexpected.

Хуки из функции

Возвращает

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

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

wc_caught_exception( $exception_object, $function, $args );
$exception_object(Throwable) (обязательный)
The exception (or error) object.
$function(строка)
The function which threw exception.
По умолчанию: ''
$args(массив)
The args passed to the function.
По умолчанию: array()

Список изменений

С версии 3.3.0 Введена.

Код wc_caught_exception() WC 11.2.2

function wc_caught_exception( $exception_object, $function = '', $args = array() ) {
	// @codingStandardsIgnoreStart
	$message  = $exception_object->getMessage();
	$message .= '. Args: ' . print_r( $args, true ) . '.';

	do_action( 'woocommerce_caught_exception', $exception_object, $function, $args );
	error_log( "Exception caught in {$function}. {$message}." );
	// @codingStandardsIgnoreEnd
}