= count($l)) $end = count($l) -1; $out = []; for ($i = $start; $i <= $end; $i++) { $out[] = $l[$i]; } return $out; } public static function handleException($e) { header("Content-Type: text/html"); header("X-Error-Message: " . $e->getMessage()); header("X-Error-Line: " . $e->getLine()); header("X-Error-File: " . $e->getFile()); header("X-Error-Code: " . $e->getCode()); $trace = $e->getTrace(); array_shift($trace); $i = 0; foreach ($trace as $t) { $i++; header("X-Error-Trace-" . $i . ": " . $t['file'] . "(" . $t['line'] . ")"); } print("
"); print("

" . $e->getMessage() . "

"); print("At Line " . $e->getLine() . " of " . $e->getFile() . "
"); $line = $e->getLine() - 1; $pre = ErrorHandler::getFileLines($e->getFile(), $line - 5, $line - 1); $line = ErrorHandler::getFileLines($e->getFile(), $line, $line); $post = ErrorHandler::getFileLines($e->getFile(), $line + 1, $line + 5); print("
");

		foreach ($pre as $l) {
			print($l . "\n");
		}
		print($line[0] . " <---\n");
		foreach ($post as $l) {
			print($l . "\n");
		}

		print("
"); print("
"); $trace = $e->getTrace(); array_shift($trace); foreach ($trace as $t) { if (array_key_exists("class", $t) && array_key_exists("function", $t)) { print("
"); print("
From " . $t['class'] . "::" . $t['function'] . "
"); print("At Line " . $t['line'] . " of " . $t['file'] . "
"); print("
"); } } } public static function handleError($num, $str, $file, $line, $context = null) { ErrorHandler::handleException(new ErrorException($str, 0, $num, $file, $line)); } public static function hook() { if (Config::get("DEBUG")) { ini_set("display_errors", "on"); error_reporting(E_ALL); } else { ini_set("display_errors", "off"); } // register_shutdown_function("ErrorHandler::checkForFatalCrash"); // set_error_handler("ErrorHandler::handleError"); // set_exception_handler("ErrorHandler::handleException"); } }