Codeigniter Catch Fatal Error
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta
Fatal Error Call To Undefined Method Codeigniter
Discuss the workings and policies of this site About Us Learn fatal error cannot redeclare class codeigniter more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack
Fatal Error Class Not Found Codeigniter
Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, fatal error unsupported operand types in codeigniter helping each other. Join them; it only takes a minute: Sign up error handling in codeigniter up vote 8 down vote favorite 4 In my project to catch all the PHP errors I have set up my error handling mechanism as follows: I have set error_reporting() in index.php file which overrides anything in the php.ini file An fatal error call to undefined function form_open() in codeigniter error handler is set in system/codeigniter/CodeIgniter.php using set_error_handler - this error handler, _exception_handler, is found in system/codeigniter/Common.php The _exception_handler function ignores E_STRICT errors, calls the show_php_error function From the Exceptions system library if the severity is that specified by your error_reporting() function in index.php and logs the error according to whatever you have set up in your config.php file The handler returns FALSE so after this PHP goes on to handle the error however it normally would according your error_reporting level and display_errors setting. The thing that is puzzling me is that E_ERROR errors i.e. fatal errors don’t seem to be being caught by _exception_handler at all. It’s not just that show_php_error isn’t being called, it looks like the function just isn’t being called for them. This is obviously a problem as it means that they aren’t get handled by show_php_error or logged. For example if I deliberately mistype $this->load->views('foo'); in a controller, the handler doesn’t get called. Any suggestion about error handling would be much appreciated, thanks! php co
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the
Catch Fatal Error In Php
company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions php catch fatal error and continue Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million
Try Catch Fatal Error
programmers, just like you, helping each other. Join them; it only takes a minute: Sign up PHP - Why isn't this fatal error being caught? up vote 0 down vote favorite function truExceptionHandler($no, $str, $file, $line) http://stackoverflow.com/questions/14778377/error-handling-in-codeigniter { if ($str != "Only variables should be assigned by reference") { echo '
'; echo "[ERROR] ".$str." in ".$file." on line ".$line."
"; print_r(debug_backtrace(2)); } } set_error_handler('truExceptionHandler'); My above function isn't catching the error Fatal error: Maximum function nesting level of '100' reached, aborting! in C:\Program Files (x86)\EasyPHP-5.3.6.0\www\site.com\system\core\Common.php on line 328 What do I need to change to be sure it's caught? php codeigniter error-handling share|improve this question asked May 4 '11 at 2:31 Webnet http://stackoverflow.com/questions/5877815/php-why-isnt-this-fatal-error-being-caught 23.3k65200345 add a comment| 3 Answers 3 active oldest votes up vote 4 down vote A fatal error is fatal. You can't catch it, PHP is now DOA. In particular, that error is a stack overflow. It makes little sense in the context of a stack overflow to expect PHP to create a new stack frame to call your error handler. share|improve this answer answered May 4 '11 at 2:33 Matthew Scharley 61.2k39149196 Then how can I determine the cause of this error? How can I figure out what functions are looping? –Webnet May 4 '11 at 2:34 @Webnet: Code inspection, or perhaps something like xdebug may be useful too. On an unrelated note, this is one of my pet peeves in PHP. –Matthew Scharley May 4 '11 at 2:35 add a comment| up vote 2 down vote Normally you cannot catch a fatal error. That's why they are called fatal errors. But, if you really want to, there's a dirty little hack that you can use. Use register_shutdown_function. Shutdown functions are still called after a FATAL_ERROR has occured. E.g: function onShutdown() { $error = error_get_last(); if (null !== $error && E_ERROR === $error['type']) { // A FATAL_ERROR occured } } register_shutdown_function('onShutdown'); Let me repeat to drive the point home: This is a dirtyfull version with proper formatting. El Forum11-17-2008, 11:01 AM [eluser]dmorin[/eluser] I'm curious if anyone has implemented something where fatal errors can be caught by codeigniter and have a nice http://forum.codeigniter.com/archive/index.php?thread-13279.html page returned to the user instead of a blank page when display_errors is turned off. There are many situations where a fatal error might be thrown on a production site. The most likely example for me is if the database is unreachable. El Forum11-19-2008, 09:46 AM [eluser]Chris Newton[/eluser] I do have something like this set up. It's a library I made called error_sender, fatal error and basically it allows me to co-opt the standard error display to suit my own purposes. It requires that display_errors be turned on though. The message shown to the user is my message however, rather than the standard PHP message, and I've changed the standard template to use something a little more visually pleasing. Code: /**
* Bn_error_sender
*
* sends errors, logs them, and shoes them to the user
*
* @package default
* @authorChris Newton <[emailprotected]>
* @version 1.1
**/
class Bn_error_sender {
/**
* $CI
*
* this stores the CodeIgniter instance object
*
* @var Object
**/
var $CI;
/**
* $send_to
*
* Configure to: email address
*
* @var string
**/
var $send_to;
/**
* $send_from
*
* Configure from: email address
*
* @var string
**/
var $send_from;
/**
* Constructor
*
* @return void
* @uses email library
* @author Chris Newton
**/
function Bn_error_sender() {
$this->CI =& get_instance();
$this->send_to="