N°4162 Portal exception page : restore exception message

Was removed with Silex to Symfony migration
This commit is contained in:
Pierre Goiffon
2021-11-18 14:53:41 +01:00
parent 500bd15843
commit a79459bc53

View File

@@ -57,11 +57,17 @@ class ExceptionListener implements ContainerAwareInterface
$oException = $oEvent->getException();
// Prepare / format exception data
$sErrorMessage = $oException->getMessage();
if ($oException instanceof \MySQLException) {
// Those exceptions should be caught before (in the metamodel startup, before event starting Symfony !)
// They could contain far too much info :/
// So as an extra precaution we are filtering here anyway !
$sErrorMessage = 'DB Server error, check error log !';
} else {
$sErrorMessage = $oException->getMessage();
}
// - For none HTTP exception, status code will be a generic 500
$iStatusCode = ($oException instanceof HttpExceptionInterface) ? $oException->getStatusCode() : Response::HTTP_INTERNAL_SERVER_ERROR;
switch ($iStatusCode)
{
switch ($iStatusCode) {
case 404:
$sErrorTitle = Dict::S('Error:HTTP:404');
break;
@@ -90,10 +96,10 @@ class ExceptionListener implements ContainerAwareInterface
// Prepare data for template
$aData = array(
'exception' => $oFlattenException,
'code' => $iStatusCode,
'error_title' => $sErrorTitle,
'error_message' => '',
'exception' => $oFlattenException,
'code' => $iStatusCode,
'error_title' => $sErrorTitle,
'error_message' => $sErrorMessage,
);
// Generate the response