c28cfa6ffe517081916dc931046da99b80c5215f
1 <?php
defined('IN_CMS') or die('No direct access allowed.');
5 public static function native($code, $error, $file, $line) {
6 // no error reporting nothing to do
7 if(error_reporting() === 0) {
11 $exception = new ErrorException($error, $code, 0, $file, $line);
13 if(in_array($code, Config
::get('error.ignore', array()))) {
14 return static::log($exception);
17 static::exception($exception);
20 public static function shutdown() {
21 if(!is_null($error = error_get_last())) {
22 extract($error, EXTR_SKIP
);
23 static::exception(new ErrorException($message, $type, 0, $file, $line));
27 public static function exception($e) {
28 // Clean the output buffer.
29 if(ob_get_level() > 0) {
37 if(Config
::get('error.detail', true)) {
38 // Get the error file.
39 $file = $e->getFile();
41 // Trim the period off of the error message.
42 $message = rtrim($e->getMessage(), '.');
44 $line = $e->getLine();
45 $trace = $e->getTraceAsString();
46 $contexts = static::context($file, $e->getLine());
48 require PATH
. 'system/admin/theme/error_php.php';
50 require PATH
. 'system/admin/theme/error_500.php';
56 private static function context($path, $line, $padding = 5) {
57 if(file_exists($path)) {
58 $file = file($path, FILE_IGNORE_NEW_LINES
);
60 array_unshift($file, '');
62 // Calculate the starting position.
63 $start = $line - $padding;
69 // Calculate the context length.
70 $length = ($line - $start) +
$padding +
1;
72 if(($start +
$length) > count($file) - 1) {
76 return array_slice($file, $start, $length, true);
82 public static function log($e) {
83 if(Config
::get('error.log')) {