From d122d6ad598b2742d09808e5d5361f7c6237fe02 Mon Sep 17 00:00:00 2001 From: Ihor Sviziev Date: Fri, 8 Jan 2021 13:48:50 +0200 Subject: [PATCH 1/4] Improve exception handling --- lib/internal/Magento/Framework/App/ExceptionHandler.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/internal/Magento/Framework/App/ExceptionHandler.php b/lib/internal/Magento/Framework/App/ExceptionHandler.php index 2bec055808aca..16655af43d27e 100644 --- a/lib/internal/Magento/Framework/App/ExceptionHandler.php +++ b/lib/internal/Magento/Framework/App/ExceptionHandler.php @@ -98,7 +98,7 @@ private function handleDeveloperMode( } } $response->setHttpResponseCode(500); - $response->setHeader('Content-Type', 'text/plain'); + $response->setHeader('Content-Type', 'text/html'); $response->setBody($this->buildContentFromException($exception)); $response->sendResponse(); return true; @@ -121,11 +121,11 @@ private function buildContentFromException(\Exception $exception): string $exceptions[] = $exception; } while ($exception = $exception->getPrevious()); - $buffer = sprintf("%d exception(s):\n", count($exceptions)); + $buffer = sprintf("
%d exception(s):
\n", count($exceptions)); foreach ($exceptions as $index => $exception) { $buffer .= sprintf( - "Exception #%d (%s): %s\n", + "
Exception #%d (%s): %s
\n", $index, get_class($exception), $exception->getMessage() @@ -134,7 +134,7 @@ private function buildContentFromException(\Exception $exception): string foreach ($exceptions as $index => $exception) { $buffer .= sprintf( - "\nException #%d (%s): %s\n%s\n", + "
\n
Exception #%d (%s): %s\n%s
\n", $index, get_class($exception), $exception->getMessage(), From f47ee3bf4e2307e334720e4d09fc5f0b92143149 Mon Sep 17 00:00:00 2001 From: Ihor Sviziev Date: Fri, 8 Jan 2021 15:31:10 +0200 Subject: [PATCH 2/4] Improve exception handling Fix unit test --- .../Magento/Framework/App/Test/Unit/ExceptionHandlerTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/internal/Magento/Framework/App/Test/Unit/ExceptionHandlerTest.php b/lib/internal/Magento/Framework/App/Test/Unit/ExceptionHandlerTest.php index 53340c7812a66..d0fd120d37022 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/ExceptionHandlerTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/ExceptionHandlerTest.php @@ -125,7 +125,7 @@ public function testHandleDeveloperMode() ->with(500); $this->responseMock->expects($this->once()) ->method('setHeader') - ->with('Content-Type', 'text/plain'); + ->with('Content-Type', 'text/html'); $constraint = new StringStartsWith('1 exception(s):'); $this->responseMock->expects($this->once()) ->method('setBody') From a43f54f3b6f0ea6306b241e30adab30ba9c58917 Mon Sep 17 00:00:00 2001 From: Ihor Sviziev Date: Fri, 8 Jan 2021 16:29:31 +0200 Subject: [PATCH 3/4] Improve exception handling Fix unit test --- .../Magento/Framework/App/Test/Unit/ExceptionHandlerTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/internal/Magento/Framework/App/Test/Unit/ExceptionHandlerTest.php b/lib/internal/Magento/Framework/App/Test/Unit/ExceptionHandlerTest.php index d0fd120d37022..0e2e0f11370f2 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/ExceptionHandlerTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/ExceptionHandlerTest.php @@ -126,7 +126,7 @@ public function testHandleDeveloperMode() $this->responseMock->expects($this->once()) ->method('setHeader') ->with('Content-Type', 'text/html'); - $constraint = new StringStartsWith('1 exception(s):'); + $constraint = new StringStartsWith('
1 exception(s):
'); $this->responseMock->expects($this->once()) ->method('setBody') ->with($constraint); From 255acf598c3a4449c9277d5957f6dc1923fabee3 Mon Sep 17 00:00:00 2001 From: engcom-Dash Date: Mon, 16 Dec 2024 15:27:25 +0530 Subject: [PATCH 4/4] 31598: fix static failures --- lib/internal/Magento/Framework/App/ExceptionHandler.php | 4 ++-- .../Magento/Framework/App/Test/Unit/ExceptionHandlerTest.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/internal/Magento/Framework/App/ExceptionHandler.php b/lib/internal/Magento/Framework/App/ExceptionHandler.php index 5b4dd7d1edd8d..d0d38804c0697 100644 --- a/lib/internal/Magento/Framework/App/ExceptionHandler.php +++ b/lib/internal/Magento/Framework/App/ExceptionHandler.php @@ -1,7 +1,7 @@