ENHANCEMENT Showing error level in custom error handlers on DebugView and CliDebugView

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@60637 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Ingo Schommer 2008-08-13 08:40:02 +00:00
parent be2d56e7d7
commit 3663221773
2 changed files with 36 additions and 3 deletions

View File

@ -27,7 +27,8 @@ class CliDebugView extends DebugView {
* Write information about the error to the screen
*/
public function writeError($httpRequest, $errno, $errstr, $errfile, $errline, $errcontext) {
echo "ERROR: $errstr\nIN $httpRequest\n";
$errorType = self::$error_types[$errno];
echo "ERROR [" . $errorType['title'] . "]: $errstr\nIN $httpRequest\n";
echo "Line $errline in $errfile\n\n";
}

View File

@ -13,6 +13,37 @@
*/
class DebugView {
protected static $error_types = array(
E_USER_ERROR => array(
'title' => 'User Error',
'class' => 'error'
),
E_CORE_ERROR => array(
'title' => 'Core Error',
'class' => 'error'
),
E_NOTICE => array(
'title' => 'Notice',
'class' => 'notice'
),
E_CORE_ERROR => array(
'title' => 'Core Error',
'class' => 'error'
),
E_WARNING => array(
'title' => 'Warning',
'class' => 'warning'
),
E_CORE_WARNING => array(
'title' => 'Core Warning',
'class' => 'warning'
),
E_USER_WARNING => array(
'title' => 'Warning',
'class' => 'warning'
)
);
/**
* Generate breadcrumb links to the URL path being displayed
*
@ -85,8 +116,9 @@ class DebugView {
* Write information about the error to the screen
*/
public function writeError($httpRequest, $errno, $errstr, $errfile, $errline, $errcontext) {
echo '<div class="info">';
echo "<h1>" . strip_tags($errstr) . "</h1>";
$errorType = self::$error_types[$errno];
echo '<div class="info ' . $errorType['class'] . '">';
echo "<h1>[" . $errorType['title'] . '] ' . strip_tags($errstr) . "</h1>";
echo "<h3>$httpRequest</h3>";
echo "<p>Line <strong>$errline</strong> in <strong>$errfile</strong></p>";
echo '</div>';