Modified handling of Error404Exception for AjaxAction-based classes
This commit is contained in:
@ -27,6 +27,12 @@ class ErrorAction extends Action
|
|||||||
{
|
{
|
||||||
$this->template = 500;
|
$this->template = 500;
|
||||||
if ($this->exception instanceof Error404Exception) {
|
if ($this->exception instanceof Error404Exception) {
|
||||||
|
if ($this->isAjaxActionError()) {
|
||||||
|
if (!headers_sent()) {
|
||||||
|
header('HTTP/1.0 404 Not Found');
|
||||||
|
die();
|
||||||
|
}
|
||||||
|
}
|
||||||
$this->template = 404;
|
$this->template = 404;
|
||||||
}
|
}
|
||||||
$this->logError();
|
$this->logError();
|
||||||
@ -76,9 +82,24 @@ class ErrorAction extends Action
|
|||||||
$error = 'Unknown Error';
|
$error = 'Unknown Error';
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
$message = 'PHP ' . $error . ': ' . $ex->getMessage() . ' in ' . $ex->getFile()
|
$message = 'PHP ' . $error . ': ' . $ex->getMessage() . ' in ' . $ex->getFile()
|
||||||
. ' on line ' . $ex->getLine();
|
. ' on line ' . $ex->getLine();
|
||||||
error_log($message);
|
error_log($message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check, if exception was thrown from AjaxAction Class
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
protected function isAjaxActionError()
|
||||||
|
{
|
||||||
|
$trace = $this->exception->getTrace();
|
||||||
|
foreach ($trace as $line) {
|
||||||
|
if (isset($line['class']) && $line['class'] === 'AjaxAction') {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
Reference in New Issue
Block a user