Permalink
Browse files

[errorhandler] support E_DEPRECATED, E_STRICT, E_ERROR & smart results

  • Loading branch information...
nao-pon committed May 1, 2015
1 parent fb100b7 commit 310fa0ce84fbc8790e08666361c1a7a045a11438
Showing with 36 additions and 9 deletions.
  1. +36 −9 html/class/errorhandler.php
@@ -147,31 +147,54 @@ function renderErrors()
return $output;
}
$output = array();
foreach( $this->_errors as $error )
{
switch ( $error['errno'] )
{
case E_USER_NOTICE:
$output .= "Notice [Xoops]: ";
$out = "Notice [Xoops]: ";
break;
case E_USER_WARNING:
$output .= "Warning [Xoops]: ";
$out = "Warning [Xoops]: ";
break;
case E_USER_ERROR:
$output .= "Error [Xoops]: ";
$out = "Error [Xoops]: ";
break;
case E_USER_DEPRECATED:
$out = "Deprecated [Xoops]: ";
break;
case E_USER_STRICT:
$out = "Strict [Xoops]: ";
break;
case E_NOTICE:
$output .= "Notice [PHP]: ";
$out = "Notice [PHP]: ";
break;
case E_WARNING:
$output .= "Warning [PHP]: ";
$out = "Warning [PHP]: ";
break;
case E_DEPRECATED:
$out = "Deprecated [PHP]: ";
break;
case E_STRICT:
$out = "Strict [PHP]: ";
break;
case E_ERROR:
$out = "Fatal [PHP]: ";
break;
default:
$output .= "Unknown Condition [" . $error['errno'] . "]: ";
$out = "Unknown Condition [" . $error['errno'] . "]: ";
}
$out .= sprintf( "%s in file %s line %s", $error['errstr'], $error['errfile'], $error['errline'] );
$md5 = md5($out);
if (isset($output[$md5])) {
$output[$md5] = preg_replace('/\(\d+\)$/', '(' . ++$count[$md5] . ')', $output[$md5]);
} else {
$output[$md5] = $out . ' (1)';
$count[$md5] = 1;
}
$output .= sprintf( "%s in file %s line %s<br />\n", $error['errstr'], $error['errfile'], $error['errline'] );
}
return $output;
return join("<br />\n", $output);
}
}
@@ -196,7 +219,7 @@ function XoopsErrorHandler_HandleError($errNo, $errStr, $errFile, $errLine)
$new_error = array(
'errno' => $errNo,
'errstr' => $errStr,
'errfile' => preg_replace("|^" . XOOPS_ROOT_PATH . "/|", '', $errFile),
'errfile' => str_replace(array(XOOPS_ROOT_PATH, XOOPS_TRUST_PATH), array('(html)', '(trust)'), $errFile),
'errline' => $errLine
);
$error_handler =& XoopsErrorHandler::getInstance();
@@ -211,6 +234,10 @@ function XoopsErrorHandler_HandleError($errNo, $errStr, $errFile, $errLine)
*/
function XoopsErrorHandler_Shutdown()
{
$error = error_get_last();
if ($error['type'] === E_ERROR) {
XoopsErrorHandler_HandleError($error['type'], $error['message'], $error['file'], $error['line']);
}
$error_handler =& XoopsErrorHandler::getInstance();
echo $error_handler->renderErrors();
}

0 comments on commit 310fa0c

Please sign in to comment.