Browse Source

Modified handling of Error404Exception for AjaxAction-based classes

master
Anton Terekhov 14 years ago
parent
commit
d93edd1ea7
  1. 21
      app/ErrorAction.php

21
app/ErrorAction.php

@ -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();
@ -81,4 +87,19 @@ class ErrorAction extends Action
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;
}
} }
Loading…
Cancel
Save