Skip to content

Commit f2da276

Browse files
committed
N°8781 - Improve twig base controller render error report
1 parent 5dd450e commit f2da276

File tree

4 files changed

+21
-0
lines changed

4 files changed

+21
-0
lines changed

dictionaries/en.dictionary.itop.ui.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -506,6 +506,7 @@
506506
'UI:Error:MaintenanceMode' => 'Application is currently in maintenance',
507507
'UI:Error:MaintenanceTitle' => 'Maintenance',
508508
'UI:Error:InvalidToken' => 'Error: the requested operation has already been performed (CSRF token not found)',
509+
'UI:Error:FormController' => 'Internal error in form controller',
509510

510511
'UI:Error:SMTP:UnknownVendor' => 'OAuth SMTP provider %1$s does not exist (email_transport_smtp.oauth.provider)',
511512

dictionaries/fr.dictionary.itop.ui.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -500,6 +500,7 @@
500500
'UI:Error:MaintenanceMode' => 'L\'application est en maintenance',
501501
'UI:Error:MaintenanceTitle' => 'Maintenance',
502502
'UI:Error:InvalidToken' => 'Erreur: l\'opération a déjà été effectuée (CSRF token not found)',
503+
'UI:Error:FormController' => 'Erreur interne',
503504
'UI:Error:SMTP:UnknownVendor' => 'Le provider SMTP OAuth 2.0 %1$s n\'existe pas',
504505
'UI:GroupBy:Count' => 'Nombre',
505506
'UI:GroupBy:Count+' => 'Nombre d\'éléments',

sources/Application/TwigBase/Controller/Controller.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -776,6 +776,7 @@ private function RenderTemplate($aParams, $sName, $sTemplateFileExtension)
776776
}
777777
catch (SyntaxError $e) {
778778
IssueLog::Error($e->getMessage().' - file: '.$e->getFile().'('.$e->getLine().')');
779+
return $this->m_oTwig->render('application/forms/itop_error.html.twig', ['sControllerError' => $e->getMessage()]);
779780
}
780781
catch (Error $e) {
781782
if (strpos($e->getMessage(), 'Unable to find template') === false)
@@ -825,6 +826,7 @@ private function CreatePage($sPageType)
825826
}
826827
$this->m_oTwig->addGlobal('UIBlockParent', [$this->m_oPage]);
827828
$this->m_oTwig->addGlobal('oPage', $this->m_oPage);
829+
$this->m_oTwig->addGlobal('debug', utils::IsDevelopmentEnvironment());
828830
}
829831

830832
/**
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{# @copyright Copyright (C) 2010-2025 Combodo SARL #}
2+
{# @license http://opensource.org/licenses/AGPL-3.0 #}
3+
4+
{% if debug %}
5+
{% if sControllerError %}
6+
{% UIContentBlock ForCode { sCode:'' } %}
7+
{{ dump(sControllerError) }}
8+
{% EndUIContentBlock %}
9+
{% endif %}
10+
{% UIContentBlock ForCode { sCode:'' } %}
11+
{{ dump(_context) }}
12+
{% EndUIContentBlock %}
13+
{% else %}
14+
{% if sControllerError and not debug %}
15+
{% UIAlert ForDanger { sTitle:'UI:Error:FormController'|dict_s, sContent:sControllerError } %}{% EndUIAlert %}
16+
{% endif %}
17+
{% endif %}

0 commit comments

Comments
 (0)