|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2015-11-03 14:47 UTC] mjauram at gmail dot com
Description: ------------ If loading classes dynamically inside of the finally block's try-catch block then auto load throws previously throwed exception which is catched. Test script: --------------- Full example here: https://goo.gl/08KRD2 try { throw new \Exception('Exception'); } catch (\Exception $e) { throw new \Exception('New Exception'); } finally { try{ myclass2::test(); // spl_autoload_register function to load classes } catch (\Exception $ex) { var_dump('this is not expected:', $ex); // this is not expected but "New Exception" is caught here } } Expected result: ---------------- New Exception is thrown not catched. PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Nov 03 03:00:01 2025 UTC |
The same situation with this bug: <?php spl_autoload_register(function ($class_name) { echo "Need to include `{$class_name}` \n"; }); try { try { throw new \RuntimeException('Error message'); } finally { echo 'Start finally block' . PHP_EOL; $foo = new Foo(); echo 'End finally block' . PHP_EOL; } } catch (\Exception $e) { echo $e->getMessage() . PHP_EOL; echo $e . PHP_EOL; } Actual result: Start finally block Need to include `Foo` Error message exception 'RuntimeException' with message 'Error message' in /in/Bn1d8:8 Stack trace: #0 {main} Expected result: Start finally block Need to include `Foo` Fatal error: Uncaught RuntimeException: Error message in /in/Bn1d8:8 Stack trace: #0 {main} Next Error: Class 'Foo' not found in /in/Bn1d8:11 Stack trace: #0 {main} thrown in /in/Bn1d8 on line 11 Process exited with code 255.