N°2060 - Migrate error page to the Symfony framework

This commit is contained in:
Molkobain
2020-01-30 13:49:42 +01:00
parent c6325dce8e
commit f990a83453
6 changed files with 217 additions and 139 deletions

View File

@@ -2,10 +2,7 @@
{# Base error layout #}
{% extends 'itop-portal-base/portal/templates/layout.html.twig' %}
{% block pNavigationWrapper %}
{% endblock %}
{% block pMainWrapper %}
{% block pStyleinline %}
<style>
.well {
margin: 50px auto;
@@ -24,18 +21,34 @@
p a.btn {
margin: 0 5px;
}
h1 .ion {
vertical-align: -5%;
margin-right: 5px;
}
abbr[title]{
border-bottom: none;
}
.traces.list_exception{
text-align: left;
}
{# Stack trace is only displayed in debug #}
{% if app['kernel'].debug == true %}
code {
background-color: transparent;
}
{# Include SF style for the stack trace #}
{{ include('@Twig/exception.css.twig') }}
{# In production (SF context, not iTop), we hide some element as the code will not be displayed #}
{% if app['kernel'].environment == 'prod' %}
.trace-line-header > .icon{
display: none !important;
}
.trace-code{
display: none !important;
}
{% endif %}
{% endif %}
</style>
{% endblock %}
{% block pNavigationWrapper %}
{% endblock %}
{% block pMainWrapper %}
<div class="container">
<div class="well">
<h1><div class="ion ion-alert-circled"></div> {{ error_title }}</h1>
@@ -44,21 +57,40 @@
<p>
<a class="btn btn-default" href="#" onclick="history.back(); return false;"><span class="fas fa-arrow-left"></span> {{ 'Page:GoPreviousPage'|dict_s }}</a>
<a class="btn btn-default" href=""><span class="fas fa-redo"></span> {{ 'Page:ReloadPage'|dict_s }}</a>
<a class="btn btn-default" href="{{ app.url_generator.generate('p_home') }}"><span class="fas fa-home"></span> {{ 'Page:GoPortalHome'|dict_s }}</a>
<a class="btn btn-default" href="{{ app['url_generator'].generate('p_home') }}"><span class="fas fa-home"></span> {{ 'Page:GoPortalHome'|dict_s }}</a>
</p>
</div>
{% if app['kernel'].debug == true %}
<div class="well">
<ol class="traces list_exception">
{% for aStep in debug_trace_steps %}
<li>
{% if aStep.function_call is not null %}at <abbr title="{{ aStep.class_fq }}">{{ aStep.function_call }}</abbr>{% endif %}
in <a title="{{ aStep.file_fq }}">{{ aStep.file_name }}</a> line {{ aStep.line }}
</li>
<div class="exceptions-container">
{# Note: The following is copied by the '@Twig/Exception/exception.html.twig' #}
{% set exception_as_array = exception.toarray %}
{% set _exceptions_with_user_code = [] %}
{% for i, e in exception_as_array %}
{% for trace in e.trace %}
{% if (trace.file is not empty) and ('/vendor/' not in trace.file) and ('/var/cache/' not in trace.file) and not loop.last %}
{% set _exceptions_with_user_code = _exceptions_with_user_code|merge([i]) %}
{% endif %}
{% endfor %}
</ol>
{% endfor %}
<h3 class="tab-title">
{% if exception_as_array|length > 1 %}
Exceptions <span class="badge">{{ exception_as_array|length }}</span>
{% else %}
Exception
{% endif %}
</h3>
<div class="tab-content">
{% for i, e in exception_as_array %}
{{ include('@Twig/Exception/traces.html.twig', { exception: e, index: loop.index, expand: i in _exceptions_with_user_code or (_exceptions_with_user_code is empty and loop.first) }, with_context = false) }}
{% endfor %}
</div>
</div>
{% endif %}
</div>
{% endblock %}
{% block pPageLiveScripts %}
{{ include('@Twig/base_js.html.twig') }}
{% endblock %}