Splendonia
Splendonia

Reputation: 1369

Symfony2 - Custom error pages are never shown

I'm trying to customize the error.html.twig, error403.html.twig, error404.html.twig and error500.html.twig, so far i've tried to get the error403.html.twig error caused by an a AccessDeniedExceptionw which is a 403 forbidden, but it displays the custom error page. I created the templates inside app/Resources/TwigBundle/views/Exception like it says here but so far, no luck.

All the templates extend the website base template

403:

    {% extends '::base.html.twig' %}
{% block body %}
<div id="header">
    <a href="{{path ('login')}}" class="fl"><img src="{{ asset('images/access_error.png') }}" alt="TiCad" /></a>
    <div class="fr"><h1>HA OCURRIDO UN ERROR:</h1></div>
    <div align="center">No posee permisos suficientes para acceder a esta seccion, si desea ingresar con otra cuenta haga clic <a href="{{path ('login')}}">AQUI</a></div>
{% endblock %}

404:

{% extends '::base.html.twig' %}
{% block body %}
<div id="header">
    <a href="{{path ('login')}}" class="fl"><img src="{{ asset('images/error404.png') }}" alt="TiCad" /></a>
    <div class="fr"><h1>HA OCURRIDO UN ERROR:</h1></div>
    <div align="center">No encontrado. Por favor, intente de nuevo.</div>
{% endblock %}

500:

{% extends '::base.html.twig' %}
{% block body %}
        <h1><img src="{{ asset('images/internal_server.png') }}" alt="Monse" />Oops! Ha ocurrido un error</h1>
        <h2>Error interno en el servidor</h2>


        <div>
            Algo no funciona. Por favor, Háznos saber que estabas haciendo cuando ocurrio este error, envia un email a <a href="mailto:[email protected]">[email protected]</a>
            Lo arreglaremos lo mas pronto posible. iCad Diseno Inteligente, C.A. se disculpa por los inconvenientes causados. 
        </div>
{% endblock %}

What am i doing wrong?

Upvotes: 2

Views: 2992

Answers (3)

Jevgenij Evll
Jevgenij Evll

Reputation: 1889

Custom templates won't show in your dev. environment. You can test them using production environment, just make sure to clear the cache.

Upvotes: 2

Flip
Flip

Reputation: 4908

It will throw an error on this line: {% extends '::base.html.twig' %}

You can check your webserver logs; possibly your symfony logs too for the error.

See also:

I'm also trying to display the error message within the layout i already have, with no luck so far.

Upvotes: 1

banban
banban

Reputation: 72

Have yo cleared the cache? Also, could you give us the names of your error files?

Upvotes: 0

Related Questions