Skip to content

Commit f9aa6cd

Browse files
[HttpKernel] Skip logging uncaught exceptions in ErrorHandler, assume $kernel->terminateWithException() will do it
1 parent 610e4c1 commit f9aa6cd

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

EventListener/DebugHandlersListener.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ public function configure(?object $event = null)
8282
return;
8383
}
8484
$this->firstCall = $this->hasTerminatedWithException = false;
85+
$hasRun = null;
8586

8687
$handler = set_exception_handler('is_int');
8788
$handler = \is_array($handler) ? $handler[0] : null;
@@ -144,6 +145,19 @@ public function configure(?object $event = null)
144145
if ($this->exceptionHandler) {
145146
if ($handler instanceof ErrorHandler) {
146147
$handler->setExceptionHandler($this->exceptionHandler);
148+
if (null !== $hasRun) {
149+
$throwAt = $handler->throwAt(0) | \E_ERROR | \E_CORE_ERROR | \E_COMPILE_ERROR | \E_USER_ERROR | \E_RECOVERABLE_ERROR | \E_PARSE;
150+
$loggers = [];
151+
152+
foreach ($handler->setLoggers([]) as $type => $log) {
153+
if ($type & $throwAt) {
154+
$loggers[$type] = [null, $log[1]];
155+
}
156+
}
157+
158+
// Assume $kernel->terminateWithException() will log uncaught exceptions appropriately
159+
$handler->setLoggers($loggers);
160+
}
147161
}
148162
$this->exceptionHandler = null;
149163
}

0 commit comments

Comments
 (0)