From a79459bc5331076ce425cb209afcce54250b0d36 Mon Sep 17 00:00:00 2001 From: Pierre Goiffon Date: Thu, 18 Nov 2021 14:53:41 +0100 Subject: [PATCH] =?UTF-8?q?N=C2=B04162=20Portal=20exception=20page=20:=20r?= =?UTF-8?q?estore=20exception=20message=20Was=20removed=20with=20Silex=20t?= =?UTF-8?q?o=20Symfony=20migration?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/EventListener/ExceptionListener.php | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/datamodels/2.x/itop-portal-base/portal/src/EventListener/ExceptionListener.php b/datamodels/2.x/itop-portal-base/portal/src/EventListener/ExceptionListener.php index 633acea61e..d67cf0a8eb 100644 --- a/datamodels/2.x/itop-portal-base/portal/src/EventListener/ExceptionListener.php +++ b/datamodels/2.x/itop-portal-base/portal/src/EventListener/ExceptionListener.php @@ -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