Closed
Description
Summary (*)
I noticed that the inner try/catch in the run
method in lib/internal/App/Bootstrap.php
does not catch throwables. I was wondering if there is any downside in adding a catch for a \Throwable
.
Examples (*)
If an error is thrown (for example, a TypeError) it currently shows a browser generic 500 error.
Proposed solution
I would suggest adding the following catch block for minimal changes as a quite a lot of other methods, like the catchException
method for example, expect an instance of \Exception, and a TypeError isn't of that type.
catch (\Throwable $e) {
\Magento\Framework\Profiler::stop('magento');
$this->objectManager->get(LoggerInterface::class)->error($e->getMessage());
// Convert the Throwable to an exception to make it compatible with catchException
$ex = new \Exception($e->getMessage(), $e->getCode(), $e);
if (!$application->catchException($this, $ex)) {
throw $ex;
}
}
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
Done