From 15d6c74dd54f825b42e3f1754eba9a83b5a33c46 Mon Sep 17 00:00:00 2001 From: Andrei Shapiro Date: Wed, 25 Sep 2024 16:49:18 +0300 Subject: [PATCH] chore: silence an error and log it --- common/oatbox/event/EventManager.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/common/oatbox/event/EventManager.php b/common/oatbox/event/EventManager.php index 29542f3a5..79c38d6a3 100644 --- a/common/oatbox/event/EventManager.php +++ b/common/oatbox/event/EventManager.php @@ -23,6 +23,7 @@ use oat\oatbox\service\ConfigurableService; use oat\oatbox\service\ServiceNotFoundException; +use Throwable; /** * The simple placeholder ServiceManager @@ -64,7 +65,17 @@ public function trigger($event, $params = []) } } - call_user_func($callback, $event); + try { + call_user_func($callback, $event); + } catch (Throwable $exception) { + $this->logError( + sprintf( + 'An error occurred during triggering an event callback: %s. Trace: %s', + $exception->getMessage(), + $exception->getTraceAsString() + ) + ); + } } }