Completed
Push — sentry-integration ( d14213 )
by
unknown
61:49
created

ExceptionController::onExceptionAction()   B

Complexity

Conditions 3
Paths 4

Size

Total Lines 29
Code Lines 16

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 29
rs 8.8571
cc 3
eloc 16
nc 4
nop 2
1
<?php
2
3
namespace SumoCoders\FrameworkCoreBundle\Controller;
4
5
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
6
use Symfony\Component\Debug\Exception\FlattenException;
7
use Symfony\Component\HttpKernel\Log\DebugLoggerInterface;
8
use Symfony\Component\Translation\Translator;
9
10
final class ExceptionController extends Controller
11
{
12
    public function onExceptionAction(
13
        FlattenException $exception,
14
        DebugLoggerInterface $logger = null
0 ignored issues
show
Unused Code introduced by
The parameter $logger is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
15
    ) {
16
        /** @var Translator $translator */
17
        $translator = $this->get('translator');
18
        $message = $translator->trans('error.messages.generic');
19
20
        // check if the error is whitelisted to overrule the message
21
        if (in_array(
22
            $exception->getClass(),
23
            $this->container->getParameter('show_messages_for')
24
        )) {
25
            $message = $exception->getMessage();
26
        }
27
28
        // translate page not found messages
29
        if ('Symfony\Component\HttpKernel\Exception\NotFoundHttpException' == $exception->getClass()) {
30
            $message = $translator->trans('error.messages.noRouteFound');
31
        }
32
33
        return $this->render(
34
            '@SumoCodersFrameworkCore/Exception/error.html.twig',
35
            array(
36
                'status_code' => $exception->getStatusCode(),
37
                'status_text' => $message,
38
            )
39
        );
40
    }
41
}
42