Skip to content

Commit fb58cb3

Browse files
committed
Log error if hook execution fails
1 parent 523c8fc commit fb58cb3

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

library/Icinga/Application/Hook/RequestHook.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
namespace Icinga\Application\Hook;
44

55
use Icinga\Application\Hook;
6+
use Icinga\Application\Logger;
67
use Icinga\Web\Request;
8+
use Throwable;
79

810
abstract class RequestHook extends Hook
911
{
@@ -26,7 +28,11 @@ abstract public function onPostDispatch(Request $request): void;
2628
final public static function postDispatch(Request $request): void
2729
{
2830
foreach (static::all('Request') as $hook) {
29-
$hook->onPostDispatch($request);
31+
try {
32+
$hook->onPostDispatch($request);
33+
} catch (Throwable $e) {
34+
Logger::error('Failed to execute hook on request: %s', $e);
35+
}
3036
}
3137
}
3238
}

0 commit comments

Comments
 (0)