Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Throwable instead of Exception in the exception and error listeners #1050

Merged
merged 1 commit into from
Dec 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions core-bundle/src/EventListener/ExceptionConverterListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public function onKernelException(ExceptionEvent $event): void
}
}

private function getTargetClass(\Exception $exception): ?string
private function getTargetClass(\Throwable $exception): ?string
{
foreach (self::MAPPER as $source => $target) {
if ($exception instanceof $source) {
Expand All @@ -78,7 +78,7 @@ private function getTargetClass(\Exception $exception): ?string
return null;
}

private function convertToHttpException(\Exception $exception, string $target): ?HttpException
private function convertToHttpException(\Throwable $exception, string $target): ?HttpException
{
switch ($target) {
case 'AccessDeniedHttpException':
Expand Down
6 changes: 3 additions & 3 deletions core-bundle/src/EventListener/PrettyErrorScreenListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ private function getTemplateParameters(string $view, int $statusCode, ExceptionE
];
}

private function logException(\Exception $exception): void
private function logException(\Throwable $exception): void
{
if (Kernel::VERSION_ID >= 40100 || null === $this->logger || !$this->isLoggable($exception)) {
return;
Expand All @@ -240,7 +240,7 @@ private function logException(\Exception $exception): void
$this->logger->critical('An exception occurred.', ['exception' => $exception]);
}

private function isLoggable(\Exception $exception): bool
private function isLoggable(\Throwable $exception): bool
{
do {
if ($exception instanceof InvalidRequestTokenException) {
Expand All @@ -251,7 +251,7 @@ private function isLoggable(\Exception $exception): bool
return true;
}

private function getStatusCodeForException(\Exception $exception): int
private function getStatusCodeForException(\Throwable $exception): int
{
if ($exception instanceof HttpException) {
return (int) $exception->getStatusCode();
Expand Down