1 <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
5 * An open source application development framework for PHP 4.3.2 or newer
8 * @author ExpressionEngine Dev Team
9 * @copyright Copyright (c) 2008, EllisLab, Inc.
10 * @license http://codeigniter.com/user_guide/license.html
11 * @link http://codeigniter.com
16 // ------------------------------------------------------------------------
21 * @package CodeIgniter
22 * @subpackage Libraries
23 * @category Exceptions
24 * @author ExpressionEngine Dev Team
25 * @link http://codeigniter.com/user_guide/libraries/exceptions.html
37 E_WARNING => 'Warning',
38 E_PARSE => 'Parsing Error',
40 E_CORE_ERROR => 'Core Error',
41 E_CORE_WARNING => 'Core Warning',
42 E_COMPILE_ERROR => 'Compile Error',
43 E_COMPILE_WARNING => 'Compile Warning',
44 E_USER_ERROR => 'User Error',
45 E_USER_WARNING => 'User Warning',
46 E_USER_NOTICE => 'User Notice',
47 E_STRICT => 'Runtime Notice'
55 function CI_Exceptions()
57 $this->ob_level = ob_get_level();
58 // Note: Do not log messages from this constructor.
61 // --------------------------------------------------------------------
66 * This function logs PHP generated error messages
69 * @param string the error severity
70 * @param string the error string
71 * @param string the error filepath
72 * @param string the error line number
75 function log_exception($severity, $message, $filepath, $line)
77 $severity = ( ! isset($this->levels[$severity])) ? $severity : $this->levels[$severity];
79 log_message('error', 'Severity: '.$severity.' --> '.$message. ' '.$filepath.' '.$line, TRUE);
82 // --------------------------------------------------------------------
85 * 404 Page Not Found Handler
91 function show_404($page = '')
93 $heading = "404 Page Not Found";
94 $message = "The page you requested was not found.";
96 log_message('error', '404 Page Not Found --> '.$page);
97 echo $this->show_error($heading, $message, 'error_404');
101 // --------------------------------------------------------------------
106 * This function takes an error message as input
107 * (either as a string or an array) and displays
108 * it using the specified template.
111 * @param string the heading
112 * @param string the message
113 * @param string the template name
116 function show_error($heading, $message, $template = 'error_general')
118 $message = '<p>'.implode('</p><p>', ( ! is_array($message)) ? array($message) : $message).'</p>';
120 if (ob_get_level() > $this->ob_level + 1)
125 include(APPPATH.'errors/'.$template.EXT);
126 $buffer = ob_get_contents();
131 // --------------------------------------------------------------------
134 * Native PHP error handler
137 * @param string the error severity
138 * @param string the error string
139 * @param string the error filepath
140 * @param string the error line number
143 function show_php_error($severity, $message, $filepath, $line)
145 $severity = ( ! isset($this->levels[$severity])) ? $severity : $this->levels[$severity];
147 $filepath = str_replace("\\", "/", $filepath);
149 // For safety reasons we do not show the full file path
150 if (FALSE !== strpos($filepath, '/'))
152 $x = explode('/', $filepath);
153 $filepath = $x[count($x)-2].'/'.end($x);
156 if (ob_get_level() > $this->ob_level + 1)
161 include(APPPATH.'errors/error_php'.EXT);
162 $buffer = ob_get_contents();
169 // END Exceptions Class
171 /* End of file Exceptions.php */
172 /* Location: ./system/libraries/Exceptions.php */