Skip to content

Commit c298521

Browse files
committed
Merge remote-tracking branch 'l3/MC-38770' into BUGFIX-11-23
2 parents d3253e1 + 3e88e17 commit c298521

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

lib/internal/Magento/Framework/App/Bootstrap.php

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use Magento\Framework\Autoload\Populator;
1414
use Magento\Framework\Config\File\ConfigFilePool;
1515
use Magento\Framework\Filesystem\DriverPool;
16+
use Magento\Framework\HTTP\PhpEnvironment\Response;
1617
use Psr\Log\LoggerInterface;
1718

1819
/**
@@ -386,7 +387,7 @@ private function initErrorHandler()
386387
$handler = new ErrorHandler();
387388
set_error_handler([$handler, 'handler']);
388389
}
389-
390+
390391
/**
391392
* Getter for error code
392393
*
@@ -428,9 +429,13 @@ public function isDeveloperMode()
428429
*/
429430
protected function terminate(\Throwable $e)
430431
{
431-
432+
/** @var Response $response */
433+
$response = $this->objectManager->get(Response::class);
434+
$response->clearHeaders();
435+
$response->setHttpResponseCode(500);
436+
$response->setHeader('Content-Type', 'text/plain');
432437
if ($this->isDeveloperMode()) {
433-
echo $e;
438+
$response->setBody($e);
434439
} else {
435440
$message = "An error has happened during application run. See exception log for details.\n";
436441
try {
@@ -441,8 +446,9 @@ protected function terminate(\Throwable $e)
441446
} catch (\Exception $e) {
442447
$message .= "Could not write error message to log. Please use developer mode to see the message.\n";
443448
}
444-
echo $message;
449+
$response->setBody($message);
445450
}
451+
$response->sendResponse();
446452
exit(1);
447453
}
448454
// phpcs:enable

0 commit comments

Comments
 (0)