0) { ob_clean(); } // log exception static::log($e); // Display error if(Config::get('error.detail', true)) { // Get the error file. $file = $e->getFile(); // Trim the period off of the error message. $message = rtrim($e->getMessage(), '.'); $line = $e->getLine(); $trace = $e->getTraceAsString(); $contexts = static::context($file, $e->getLine()); require PATH . 'system/admin/theme/error_php.php'; } else { require PATH . 'system/admin/theme/error_500.php'; } exit(1); } private static function context($path, $line, $padding = 5) { if(file_exists($path)) { $file = file($path, FILE_IGNORE_NEW_LINES); array_unshift($file, ''); // Calculate the starting position. $start = $line - $padding; if($start < 0) { $start = 0; } // Calculate the context length. $length = ($line - $start) + $padding + 1; if(($start + $length) > count($file) - 1) { $length = null; } return array_slice($file, $start, $length, true); } return array(); } public static function log($e) { if(Config::get('error.log')) { Log::exception($e); } } }