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