RE: How you will work with error handling in codeigniter?

How you will work with error handling in codeigniter?

dip Team Leader Asked on June 7, 2018 in CODEIGNITER.
Add Comment
1 Answers

Blunder works in codeigniter are basic procedural interfaces that are accessible all inclusive all through the application, consequently the mistake messages are activated without thinking about the class/work scope.

CodeIgniter encourages us to report mistakes into our applications by utilizing the accompanying capacities:


This capacity shows the mistake message utilizing the layout in application/blunders/error_general.php.

Syntax of show_error() function is:


Here, the parameter message is required and is the string mistake message to be appeared and the parameter status_code is discretionary which is a whole number esteem speaking to the HTTP status code to be sent with the mistake.

Code Example:

show_error('File not found!');



This capacity shows the 404 mistake message provided to it by the format in application/blunders/error_404.php.

Sentence structure of show_404() work is:



The principal parameter page in show_404() work is the way of the page that isn’t found. By and large we can see that 404 messages are appeared by codeigniter naturally, if the controllers are not found.

The second parameter log_error is discretionary and has boolean esteem i.e. genuine or false. On the off chance that it is set to esteem false, codeigniter won’t log any show_404() calls and the other way around in the event that it is valid.

Code Example:



Everytime a page is run, a log document is produced. These log documents are under designer’s control.

This capacity enables you to compose messages in the log document.

Syntax of log_message() function is:



The primary parameter level demonstrates which sort of blunder message you need to log. There are 3 dimensions of blunder message troubleshoot, mistake and data.The message is the second parameter.

Code Example:

log_message('error','username is unfilled');


Team Leader Answered on November 18, 2018.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.