3 namespace Rapsys\AirBundle\Controller
;
5 use Symfony\Component\HttpFoundation\Request
;
6 use Symfony\Component\HttpFoundation\Response
;
7 #use Symfony\Component\Security\Core\Exception\AccessDeniedException;
8 #use Symfony\Component\Security\Http\Authorization\AccessDeniedHandlerInterface;
9 #use Symfony\Component\DependencyInjection\ContainerInterface;
10 #use Symfony\Component\Routing\RouterInterface;
11 #use Symfony\Component\Translation\TranslatorInterface;
12 #use Twig\Environment;
14 #use Symfony\Component\Debug\Exception\FlattenException;
15 use Symfony\Component\ErrorHandler\Exception\FlattenException
;
17 class ErrorController
extends DefaultController
{
21 public function show(Request
$request, FlattenException
$exception) {
23 $section = $exception->getStatusCode().' '.$this->translator
->trans($exception->getStatusText());
26 $title = $this->translator
->trans($this->config
['site']['title']).' - '.$section;
29 $message = $exception->getMessage();
34 //Prevent non admin access to trace
35 if ($this->isGranted('ROLE_ADMIN')) {
37 $projectDir = $this->container
->getParameter('kernel.project_dir').'/';
40 //$trace = $exception->getAsString();
44 foreach($exception->toArray() as $current) {
45 $trace .= $current['class'];
47 if (!empty($current['message'])) {
48 $trace .= ': '.$current['message'];
51 if (!empty($current['trace'])) {
52 foreach($current['trace'] as $id => $sub) {
53 $trace .= "\n".'#'.$id.' '.$sub['class'].$sub['type'].$sub['function'];
54 if (!empty($sub['args'])) {
55 $trace .= '('.implode(', ', array_map(function($v){return $v
[0].' '.$v
[1];}, $sub['args'])).')';
57 $trace .= ' in '.str_replace($projectDir, '', $sub['file']).':'.$sub['line'];
65 '@RapsysAir/error.html.twig',
66 ['title' => $title, 'section' => $section, 'message' => $message, 'trace' => $trace]+
$this->context