|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2008-03-09 12:09 UTC] colder@php.net
[2012-05-10 15:36 UTC] ab@php.net
[2014-10-07 23:26 UTC] stas@php.net
[2014-10-07 23:37 UTC] stas@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 26 04:00:01 2025 UTC |
Description: ------------ When set_error_handler() has been used to set a custom error handler, the RuntimeException thrown by DirectoryIterator::__construct() is not handled properly -- the user error handler runs and then code continues after the constructor instead of the exception being thrown. This is specific to DirectoryIterator, if you replace "$iter = new DirectoryIterator($dir)" with just "throw new Exception('monkey');" in the reproduce code below, the catch block executes OK. Reproduce code: --------------- <?php error_reporting(E_ALL | E_STRICT); ini_set('display_errors',true); $dir = '/this/path/does/not/exist'; set_error_handler('my_error_handler'); function my_error_handler() { print "in error handler\n"; } try { print "before\n"; $iter = new DirectoryIterator($dir); print get_class($iter) . "\n"; print "after\n"; } catch (Exception $e) { print "in catch\n"; } Expected result: ---------------- before in catch Actual result: -------------- before in error handler DirectoryIterator after