How To Grip Errors Inwards Codeigniter?

CodeIgniter lets you lot construct error reporting into your applications using the functions such as..
 show_error('message' [, int $status_code= 500 ] ) This role volition display the error message supplied to it using the next error template: application/errors/error_general.php  show_404('page' [, 'log_error']) This role volition display the 404 error message supplied to it using the next error template: application/errors/error_404.php  log_message('level', 'message') This role lets you lot write messages to your log files. You tin 3 degree options:  error, debug in addition to info. 
By default, on a fix clean install, CI volition display ALL php errors of all severity. So if you lot brand a fault inwards your PHP coding, you'll encounter the errors inwards your browser..


CI uses PHP's error_reporting() role to define the degree of error reporting, in addition to you lot tin notice this inwards the principal index.php file inwards the source of your CI install. It’s the kickoff role you lot see.


Instead of E_ALL, you lot tin modify it to whatever of the predefined error constant that PHP understands to arrange your needs. Obviously, i time your site goes live, you lot should modify from E_ALL to E_ERROR to exhibit solely messages for fatal run fourth dimension problems. This volition enshroud all php errors except those that volition stop your script execution.

How to enshroud database error?
You tin enshroud the database error yesteryear setting db_debug to FALSE inwards application/config/database.php.
It volition display blank page if whatever database error volition tumble out instead of displaying whatever sort of database tabular array cite or error on site.
   $db['default']['db_debug'] = FALSE;  
You tin easily redirect to another error page instead of showing blank page equally follows.
  $query = $this->db->get('your_table');   if(!$query) {    show_error("This is where your error message volition appear surrounded yesteryear this default template. ", 500 );    exit; } 

When you lot telephone phone show_error(), you lot volition generate page that looks similar this. The layout tin changed yesteryear modifying this file application/errors/error_general.php)


That's it. Feel gratuitous to comment.
Source: http://www.askaboutphp.com/172/codeigniter-handling-errors.html
Sumber http://developer-paradize.blogspot.com

Comments

Popular posts from this blog

What Are The Main Components of a Computer System

Top Qualities To Look For In An IT Support Team

How To Integrate Google Adwords Api Into Codeigniter?