CI_Exceptions Class Reference

List of all members.


Public Member Functions

 CI_Exceptions ()
 Constructor.
 log_exception ($severity, $message, $filepath, $line)
 Exception Logger.
 show_404 ($page= '')
 404 Page Not Found Handler
 show_error ($heading, $message, $template= 'error_general')
 General Error Page.
 show_php_error ($severity, $message, $filepath, $line)
 Native PHP error handler.

Public Attributes

 $action
 $severity
 $message
 $filename
 $line
 $ob_level
 $levels

Detailed Description

Definition at line 27 of file Exceptions.php.


Member Function Documentation

CI_Exceptions::CI_Exceptions (  ) 

Constructor.

Definition at line 55 of file Exceptions.php.

00056         {
00057                 $this->ob_level = ob_get_level();
00058                 // Note:  Do not log messages from this constructor.
00059         }

CI_Exceptions::log_exception ( severity,
message,
filepath,
line 
)

Exception Logger.

This function logs PHP generated error messages

private

Parameters:
string the error severity
string the error string
string the error filepath
string the error line number
Returns:
string

Definition at line 75 of file Exceptions.php.

References $line, $message, $severity, and log_message().

00076         {       
00077                 $severity = ( ! isset($this->levels[$severity])) ? $severity : $this->levels[$severity];
00078                 
00079                 log_message('error', 'Severity: '.$severity.'  --> '.$message. ' '.$filepath.' '.$line, TRUE);
00080         }

Here is the call graph for this function:

CI_Exceptions::show_404 ( page = ''  ) 

404 Page Not Found Handler

private

Parameters:
string 
Returns:
string

Definition at line 91 of file Exceptions.php.

References $message, log_message(), and show_error().

00092         {       
00093                 $heading = "404 Page Not Found";
00094                 $message = "The page you requested was not found.";
00095 
00096                 log_message('error', '404 Page Not Found --> '.$page);
00097                 echo $this->show_error($heading, $message, 'error_404');
00098                 exit;
00099         }

Here is the call graph for this function:

CI_Exceptions::show_error ( heading,
message,
template = 'error_general' 
)

General Error Page.

This function takes an error message as input (either as a string or an array) and displays it using the specified template.

private

Parameters:
string the heading
string the message
string the template name
Returns:
string

Definition at line 116 of file Exceptions.php.

References $message.

Referenced by show_404().

00117         {
00118                 $message = '<p>'.implode('</p><p>', ( ! is_array($message)) ? array($message) : $message).'</p>';
00119 
00120                 if (ob_get_level() > $this->ob_level + 1)
00121                 {
00122                         ob_end_flush(); 
00123                 }
00124                 ob_start();
00125                 include(APPPATH.'errors/'.$template.EXT);
00126                 $buffer = ob_get_contents();
00127                 ob_end_clean();
00128                 return $buffer;
00129         }

Here is the caller graph for this function:

CI_Exceptions::show_php_error ( severity,
message,
filepath,
line 
)

Native PHP error handler.

private

Parameters:
string the error severity
string the error string
string the error filepath
string the error line number
Returns:
string

Definition at line 143 of file Exceptions.php.

References $severity.

00144         {       
00145                 $severity = ( ! isset($this->levels[$severity])) ? $severity : $this->levels[$severity];
00146         
00147                 $filepath = str_replace("\\", "/", $filepath);
00148                 
00149                 // For safety reasons we do not show the full file path
00150                 if (FALSE !== strpos($filepath, '/'))
00151                 {
00152                         $x = explode('/', $filepath);
00153                         $filepath = $x[count($x)-2].'/'.end($x);
00154                 }
00155                 
00156                 if (ob_get_level() > $this->ob_level + 1)
00157                 {
00158                         ob_end_flush(); 
00159                 }
00160                 ob_start();
00161                 include(APPPATH.'errors/error_php'.EXT);
00162                 $buffer = ob_get_contents();
00163                 ob_end_clean();
00164                 echo $buffer;
00165         }


Member Data Documentation

CI_Exceptions::$action

Definition at line 28 of file Exceptions.php.

CI_Exceptions::$filename

Definition at line 31 of file Exceptions.php.

CI_Exceptions::$levels

Initial value:

 array(
                                                E_ERROR                         =>      'Error',
                                                E_WARNING                       =>      'Warning',
                                                E_PARSE                         =>      'Parsing Error',
                                                E_NOTICE                        =>      'Notice',
                                                E_CORE_ERROR            =>      'Core Error',
                                                E_CORE_WARNING          =>      'Core Warning',
                                                E_COMPILE_ERROR         =>      'Compile Error',
                                                E_COMPILE_WARNING       =>      'Compile Warning',
                                                E_USER_ERROR            =>      'User Error',
                                                E_USER_WARNING          =>      'User Warning',
                                                E_USER_NOTICE           =>      'User Notice',
                                                E_STRICT                        =>      'Runtime Notice'
                                        )

Definition at line 35 of file Exceptions.php.

CI_Exceptions::$line

Definition at line 32 of file Exceptions.php.

Referenced by log_exception().

CI_Exceptions::$message

Definition at line 30 of file Exceptions.php.

Referenced by log_exception(), show_404(), and show_error().

CI_Exceptions::$ob_level

Definition at line 33 of file Exceptions.php.

CI_Exceptions::$severity

Definition at line 29 of file Exceptions.php.

Referenced by log_exception(), and show_php_error().


The documentation for this class was generated from the following file: