wc_caught_exception()
When catching an exception, this allows us to log it if unexpected.
Hooks from the function
Returns
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() wc caught exception code WC 10.5.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
}