Skip to content

Commit

Permalink
bug #21064 [Debug] Wrap call to ->log in a try catch block (lyrixx)
Browse files Browse the repository at this point in the history
This PR was merged into the 2.7 branch.

Discussion
----------

[Debug] Wrap call to ->log in a try catch block

| Q             | A
| ------------- | ---
| Branch?       | 2.7
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets |
| License       | MIT
| Doc PR        |

---

If something goes wrong in the logger, the application ends up with a blank page. Let's display the original exception.

Commits
-------

18dfef1 [Debug] Wrap call to ->log in a try catch block
  • Loading branch information
nicolas-grekas committed Dec 28, 2016
2 parents ee69018 + 18dfef1 commit b4ed15a
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/Symfony/Component/Debug/ErrorHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,11 @@ public function handleException($exception, array $error = null)
}
}
if ($this->loggedErrors & $type) {
$this->loggers[$type][0]->log($this->loggers[$type][1], $message, $e);
try {
$this->loggers[$type][0]->log($this->loggers[$type][1], $message, $e);
} catch (\Exception $handlerException) {
} catch (\Throwable $handlerException) {
}
}
if ($exception instanceof FatalErrorException && !$exception instanceof OutOfMemoryException && $error) {
foreach ($this->getFatalErrorHandlers() as $handler) {
Expand Down

0 comments on commit b4ed15a

Please sign in to comment.