Skip to content

Commit

Permalink
Tweak template name generation.
Browse files Browse the repository at this point in the history
  • Loading branch information
ADmad committed Apr 20, 2014
1 parent dc0da6e commit a765f23
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions src/Error/ExceptionRenderer.php
Expand Up @@ -177,31 +177,30 @@ protected function _message(\Exception $exception, $code) {
* @return string Template name
*/
protected function _template(\Exception $exception, $code) {
if (!Configure::read('debug') &&
!($exception instanceof Error\HttpException)
) {
$isHttpException = $exception instanceof Error\HttpException;

if (!Configure::read('debug') && !$isHttpException) {
$template = 'error500';
if ($code < 500) {
$template = 'error400';
}
return $this->template = $template;
}

list(, $baseClass) = namespaceSplit(get_class($exception));
$baseClass = substr($baseClass, 0, -9);
$template = Inflector::variable($baseClass);

if (empty($template) || $template === 'internalError') {
if ($isHttpException) {
$template = 'error500';
if ($code < 500) {
$template = 'error400';
}
return $this->template = $template;
}

list(, $baseClass) = namespaceSplit(get_class($exception));
$baseClass = substr($baseClass, 0, -9);
$template = Inflector::variable($baseClass) ?: 'error500';

if ($exception instanceof \PDOException) {
$template = 'pdo_error';
} elseif ($exception instanceof Error\HttpException) {
$template = 'error500';
if ($code < 500) {
$template = 'error400';
}
}

return $this->template = $template;
Expand Down

0 comments on commit a765f23

Please sign in to comment.