Date: May 27th, 2015 (given the fast changing nature of Magento 2)
For many classes of PHP errors/exceptions in Magento 2, the default system behavior is to redirect the user to the homepage, and rely on the homepage's exception handling code to display the error.
Where does this redirect happen? Is it in a single place, or are there multiple dispatch loops where it might happen? The PHP error handler Magento sets
#File: lib/internal/Magento/Framework/App/ErrorHandler.php
public function handler($errorNo, $errorStr, $errorFile, $errorLine)
{
if (strpos($errorStr, 'DateTimeZone::__construct') !== false) {
// there's no way to distinguish between caught system exceptions and warnings
return false;
}
$errorNo = $errorNo & error_reporting();
if ($errorNo == 0) {
return false;
}
$msg = isset($this->errorPhrases[$errorNo]) ? $this->errorPhrases[$errorNo] : "Unknown error ({$errorNo})";
$msg .= ": {$errorStr} in {$errorFile} on line {$errorLine}";
throw new \Exception($msg);
}
appears to turn all PHP errors into a global Exception
. This means errors are caught somewhere in the execution chain and a redirect is dispatched -- I'm looking for the spot (or spots) where this catch and redirect behavior happens.