Skip to content

Commit

Permalink
Adding stack traces to error400 and error500 when debug > 0.
Browse files Browse the repository at this point in the history
Adding the stack trace element.
  • Loading branch information
markstory committed Sep 6, 2010
1 parent 09fd8ba commit 0f23634
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 1 deletion.
2 changes: 2 additions & 0 deletions cake/libs/error_handler.php
Expand Up @@ -222,6 +222,7 @@ public function error400($error) {
$this->controller->set(array(
'name' => $message,
'url' => h($url),
'error' => $error,
));
$this->_outputMessage('error400');
}
Expand All @@ -238,6 +239,7 @@ public function error500($error) {
$this->controller->set(array(
'name' => __('An Internal Error Has Occurred'),
'message' => h($url),
'error' => $error,
));
$this->_outputMessage('error500');
}
Expand Down
24 changes: 24 additions & 0 deletions cake/libs/view/elements/exception_stack_trace.ctp
@@ -0,0 +1,24 @@
<?php
/**
* Prints a stack trace for an exception
*
* PHP 5
*
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
* Copyright 2005-2009, Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://cakephp.org CakePHP(tm) Project
* @package cake
* @subpackage cake.cake.libs.view.templates.elements
* @since CakePHP(tm) v 1.3
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
?>
<h4>Stack Trace</h4>
<pre>
<?php echo $error->getTraceAsString(); ?>
</pre>
7 changes: 6 additions & 1 deletion cake/libs/view/errors/error400.ctp
Expand Up @@ -24,4 +24,9 @@
__('The requested address %s was not found on this server.'),
"<strong>'{$url}'</strong>"
); ?>
</p>
</p>
<?php
if (Configure::read('debug') > 0 ):
echo $this->element('exception_stack_trace');
endif;
?>
5 changes: 5 additions & 0 deletions cake/libs/view/errors/error500.ctp
Expand Up @@ -22,3 +22,8 @@
<strong><?php echo __('Error', true); ?>: </strong>
<?php echo __('An Internal Error Has Occurred.'); ?>
</p>
<?php
if (Configure::read('debug') > 0 ):
echo $this->element('exception_stack_trace');
endif;
?>

0 comments on commit 0f23634

Please sign in to comment.