wc_caught_exception()WC 3.3.0

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

Hooks from the function

Return

null. Nothing (null).

Usage

wc_caught_exception( $exception_object, $function, $args );
$exception_object(Exception) (required)
The exception object.
$function(string)
The function which threw exception.
Default: ''
$args(array)
The args passed to the function.
Default: array()

Changelog

Since 3.3.0 Introduced.

wc_caught_exception() code WC 8.7.0

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
}