Edit report at https://bugs.php.net/bug.php?id=60188&edit=1
ID: 60188 Updated by: johan...@php.net Reported by: hinikato at gmail dot com Summary: Exception handler and shutdown hanlder were not called after throwing exception -Status: Open +Status: Bogus Type: Bug Package: Scripting Engine problem Operating System: Windows 7 x64 PHP Version: 5.3.8 Block user comment: N Private report: N New Comment: Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php If a fatal error (E_ERROR) is created the engine might be in an unreliable state, we therefore can't all error handlers. Quoting the docs: "The following error types cannot be handled with a user defined function: E_ERROR, E_PARSE, E_CORE_ERROR, E_CORE_WARNING, E_COMPILE_ERROR, E_COMPILE_WARNING, and most of E_STRICT raised in the file where set_error_handler() is called. " http://php.net/set_error_handler Previous Comments: ------------------------------------------------------------------------ [2011-11-01 12:10:43] hinikato at gmail dot com Description: ------------ The neither exception handler nor fatal error handler have not been called if error handler throws exception in case of including not existent file using require_once. My PHP version is: PHP Version 5.3.8-ZS5.5.0 Test script: --------------- <?php namespace Foo; class MyErrorHandler { function __construct() { set_error_handler(array($this, 'errorHandler')); set_exception_handler(array($this, 'exceptionHandler')); register_shutdown_function(array($this, 'fatalErrorHandler')); } function errorHandler() { echo __METHOD__ . "\n"; throw new \Exception('test'); } function exceptionHandler() { echo __METHOD__ . "\n"; // should be called! } function fatalErrorHandler() { echo __METHOD__ . "\n"; // should be called! } } echo '<pre>'; $foo = new MyErrorHandler(); require_once __DIR__ . '/not_existing_file.php'; // file should not exist die(); Expected result: ---------------- Foo\MyErrorHandler::errorHandler Foo\MyErrorHandler::exceptionHandler Foo\MyErrorHandler::fatalErrorHandler Fatal error: main() [function.require]: Failed opening required 'X:\home\localhost\www/not_existing_file.php' (include_path='D:\system\home\projects\myak\www\includes') in X:\home\localhost\www\test.php on line 28 Actual result: -------------- Foo\MyErrorHandler::errorHandler Fatal error: main() [function.require]: Failed opening required 'X:\home\localhost\www/not_existing_file.php' (include_path='D:\system\home\projects\myak\www\includes') in X:\home\localhost\www\test.php on line 28 ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=60188&edit=1