CodeIgniter - Error Handling
define('ENVIRONMENT', isset($_SERVER['CI_ENV']) ? $_SERVER['CI_ENV'] : 'development');
- show_error() function displays errors in HTML format at the top of the screen.
Syntax | show_error($message, $status_code, $heading = 'An Error Was Encountered') |
Parameters |
|
Return Type | mixed |
- show_404() function displays error if you are trying to access a page which does not exist.
Syntax | show_404($page = '', $log_error = TRUE) |
Parameters |
|
Return Type | void |
- log_message() function is used to write log messages. This is useful when you want to write custom messages.
Syntax | log_message($level, $message, $php_error = FALSE) |
Parameters |
|
Return Type | void |
/*
|--------------------------------------------------------------------------------
| Error Logging Threshold
|--------------------------------------------------------------------------------
| You can enable error logging by setting a threshold over zero. The
| threshold determines what gets logged. Threshold options are:
|
| 0 = Disable logging, Error logging TURNED OFF
| 1 = Error Message (including PHP errors)
| 2 = Debug Message
| 3 = Informational Messages
| 4 = All Messages
|
| You can also pass an array with threshold levels to show individual error types
|
| array(2) = Debug Message, without Error Messages
| For a live site you'll usually only enable Errors (1) to be logged otherwise
| your log files will fill up very fast.
|
*/
$config['log_threshold'] = 0;