* @link http://netmonsters.ru * @package Majestic * @subpackage exception * @since 2010-02-26 * @version SVN: $Id$ * @filesource $URL$ */ class ErrorHandler { static public function init() { set_error_handler(array('ErrorHandler', 'error_handler')); } static public function error_handler($errno, $errstr, $errfile, $errline) { $ob_handlers = ob_get_status(); if (!empty($ob_handlers)) { ob_clean(); } throw new ErrorException($errstr, 0, $errno, $errfile, $errline); } static protected function getSource($file, $hiline) { $code = array(); $i = 0; foreach (file($file) as $line) { $i++; if ($i >= $hiline - 10 && $i <= $hiline + 10) { if ($i == $hiline) { $code[] = '
No ' . $name . ' data
'; } $text = 'Variable | Value |
---|---|
' . $key . ' | ' . $value . ' |
' . nl2br($trace) . '
';
}
/**
* @param Exception $exception
*/
static public function showDebug($exception)
{
$ob_handlers = ob_get_status();
if (!empty($ob_handlers)) {
ob_end_clean();
}
$class = get_class($exception);
$method = Env::Server('REQUEST_METHOD', '');
$uri = Env::getRequestUri();
$source = self::getSource($exception->getFile(), $exception->getLine());
$time = date('r', Env::Server('REQUEST_TIME', time()));
$trace = nl2br($exception->getTraceAsString());
$get = self::wrapArray(Env::Get(), 'GET');
$post = self::wrapArray(Env::Post(), 'POST');
$session = self::wrapArray(Session::get(), 'SESSION');
$files = self::wrapArray(Env::Files(), 'FILES');
$cookies = self::wrapArray(Env::Cookie(), 'COOKIE');
$server = self::wrapArray(Env::Server(), 'SERVER');
$message = <<{$exception->getMessage()}
Request Method: | {$method} |
---|---|
Exception Type: | {$class} |
Exception Message: | {$exception->getMessage()} |
Exception Location: | {$exception->getFile()}, line {$exception->getLine()} |
Server time: | {$time} |
In file {$exception->getFile()}
, error at line {$exception->getLine()}
{$trace}
todo
You're seeing this error because you have defined constant DEBUG = True
in your config file. Change that to False
, and it will display a standard 500 page.