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

ExceptionController   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 0
cbo 4
dl 0
loc 32
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B onExceptionAction() 0 29 3
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