top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

How you will work with error handling in codeigniter?

+6 votes
421 views
How you will work with error handling in codeigniter?
posted Aug 25, 2015 by Vrije Mani Upadhyay

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

+2 votes
 
Best answer

Error Handling

CodeIgniter build error reporting into your applications using the functions described below. In addition, it has an error logging class that permits error and debugging messages to be saved as text files.

show_error('message' [, int $status_code= 500 ] )

This function will display the error message supplied to it using the following error template:

application/errors/error_general.php

The optional parameter $status_code determines what HTTP status code should be sent with the error.

show_404('page' [, 'log_error'])

This function will display the 404 error message supplied to it using the following error template:

application/errors/error_404.php

The function expects the string passed to it to be the file path to the page that isn't found. Note that CodeIgniter automatically shows 404 messages if controllers are not found.

CodeIgniter automatically logs any show_404() calls. Setting the optional second parameter to FALSE will skip logging.

log_message('level', 'message')

This function lets you write messages to your log files. You must supply one of three "levels" in the first parameter, indicating what type of message it is (debug, error, info), with the message itself in the second parameter.

answer Sep 18, 2015 by Deepak Negi
...