From 2ef6650cb5125638bf482a78adb7edd0522eaf8a Mon Sep 17 00:00:00 2001 From: =?utf8?q?Rapha=C3=ABl=20Gertz?= Date: Wed, 11 Dec 2019 05:39:11 +0100 Subject: [PATCH 1/1] Add error controller --- Controller/ErrorController.php | 40 +++++++++++++++++++++++++++++++++ Resources/views/error.html.twig | 8 +++++++ 2 files changed, 48 insertions(+) create mode 100644 Controller/ErrorController.php create mode 100644 Resources/views/error.html.twig diff --git a/Controller/ErrorController.php b/Controller/ErrorController.php new file mode 100644 index 0000000..eb53209 --- /dev/null +++ b/Controller/ErrorController.php @@ -0,0 +1,40 @@ +getStatusCode().' '.$this->translator->trans($exception->getStatusText()); + + //Set title + $title = $section.' - '.$this->translator->trans($this->config['site']['title']); + + //Set the message + $message = $exception->getMessage(); + + //Set the trace + $trace = $exception->getAsString(); + + //Render template + return $this->render( + '@RapsysAir/error.html.twig', + ['title' => $title, 'section' => $section, 'message' => $message, 'trace' => $trace]+$this->context + ); + } +} diff --git a/Resources/views/error.html.twig b/Resources/views/error.html.twig new file mode 100644 index 0000000..8dd4a69 --- /dev/null +++ b/Resources/views/error.html.twig @@ -0,0 +1,8 @@ +{% extends '@RapsysAir/body.html.twig' %} +{% block content %} +
+

{{ section }}

+

{% if message %}{{ message }}{% else %}{% trans %}Error{% endtrans %}{% endif %}

+ {% if app.environment == 'dev' and trace is defined %}
{{ trace }}
{% endif %} +
+{% endblock %} -- 2.41.1