From 9f377383f71bfc68ad8a37b8d0e76919017b1f85 Mon Sep 17 00:00:00 2001 From: Stephen J Carnam Date: Thu, 20 Jul 2023 16:59:33 -0700 Subject: [PATCH] log/trap do_action errors --- hooks/pluginable.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/hooks/pluginable.php b/hooks/pluginable.php index 3adf434..0056b72 100644 --- a/hooks/pluginable.php +++ b/hooks/pluginable.php @@ -254,7 +254,15 @@ public function do_action( $tag, $arg = '' ) { $args[] = func_get_arg($a); foreach ( $this->hcpp_filters[$tag] as $func ) { - $arg = call_user_func_array( $func, $args ); + try { + $arg = call_user_func_array( $func, $args ); + } catch (Exception $e) { + + // Echo out the error message if an exception occurs + echo 'Error: do_action failed ' . $e->getMessage(); + $this->log( 'Error: do_action failed ' . $e->getMessage() ); + } + if ($arg != null) { $args = array(); if ( is_array($arg) && 1 == count($arg) && isset($arg[0]) && is_object($arg[0]) ) // array(&$this)