|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2005-03-06 19:19 UTC] sniper@php.net
[2005-03-06 19:56 UTC] jowag89 at gmx dot ch
[2005-03-21 23:48 UTC] sniper@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Dec 03 10:00:01 2025 UTC |
Description: ------------ When include or require (_once) triggers an error it is triggered in a different "scope" as other errors, like an above funktion or the main dummy function. Therfore when the error is handled by throwing an exception instead this will give confusing results including uncaught exceptions that actually should be caught. Reproduce code: --------------- <?php function __error_handler($type, $message, $file, $line, $context) { throw new Exception($message,$type); } set_error_handler('__error_handler',E_ALL); function test($t) { try { /* Both should trigger the error in the same context */ if ($t) include('missing_file.php'); else fopen('forgot_parameter'); } catch (Exception $e) { echo("Catched exception inside of test():\n".$e->getMessage()."\n"); } } try { test(true); } catch (Exception $e) { /* So we do not get a nasty uncaught exception error */ echo("Catched exception outside of test():\n".$e->getMessage()."\n"); } try { test(false); } catch (Exception $e) { /* So we do not get a nasty uncaught exception error */ echo("Catched exception outside of test():\n".$e->getMessage()."\n"); } ?> Expected result: ---------------- Catched both exceptions inside of test Actual result: -------------- Catches the fopen error inside but the include error outside of test.