#50454 [NEW]: set_exception_handler to work more like set_error_handler

From: Date: Fri, 11 Dec 2009 20:02:36 +0000
Subject: #50454 [NEW]: set_exception_handler to work more like set_error_handler
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-145646@lists.php.net to get a copy of this message
From: randallgirard at hotmail dot com Operating system: Windows PHP version: 5.3.1 PHP Bug Type: Feature/Change Request Bug description: set_exception_handler to work more like set_error_handler Description: ------------ When utilizing set_error_handler(), the error_handler leaves it to the scripter to decide whether or not script execution should continue or quit (die/exit, etc.) I believe it returns execution to the parent scope? (I'm not 100% sure, but that isn't my point) "Execution will stop after the exception_handler is called" I believe there should be some way to continue execution (probably in the parent scope from where the exception was thrown). Considering at the current moment (or at least the documentation does not say) the return value does nothing: What if returning (bool) TRUE (or even a value which evaluates to true) causes script execution to return to the parent scope and continue, and (bool) FALSE (or a value which evaluates to false, hence when nothing is returned) will cause the same and current result. I feel that this is the final link in the error handling routines, and am so far most satisfied with the new features in PHP 5.3.x! I am very excited about these releases!! If there is a specific reason that we are not aloud a way to return scripting when unhandled exceptions are thrown, PLEASE indicate the reason here. It is my belief that many scripters would want to throw exceptions and act like an E_USER_NOTICE, or E_USER_WARNING, compared to error handling, that is when caught in the exception_handler... <b>Especially when you combine both of the handlers to work together, which is NOT the result I expected.</b> Reproduce code: --------------- function exception_handler($exception) { echo "Uncaught exception: " , $exception->getMessage(), "\n"; } set_exception_handler('exception_handler'); function errorone() { throw new Exception("Test 1"); } function errortwo() { throw new Exception("Test 2"); } function test() { errorone(); errortwo(); } test(); test(); # I also did further tests involving class scopes that I thought might affect this, but I'm almost positive processing of the script is terminated without a way to restore it. Expected result: ---------------- Uncaught exception: Test 1\nUncaught exception: Test 2\nUncaught exception: Test 1\nUncaught exception: Test 2\n Actual result: -------------- Uncaught exception: Test 1\n -- Edit bug report at http://bugs.php.net/?id=50454&edit=1 -- Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=50454&r=trysnapshot52 Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=50454&r=trysnapshot53 Try a snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=50454&r=trysnapshot60 Fixed in SVN: http://bugs.php.net/fix.php?id=50454&r=fixed Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=50454&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=50454&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=50454&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=50454&r=needscript Try newer version: http://bugs.php.net/fix.php?id=50454&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=50454&r=support Expected behavior: http://bugs.php.net/fix.php?id=50454&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=50454&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=50454&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=50454&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=50454&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=50454&r=dst IIS Stability: http://bugs.php.net/fix.php?id=50454&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=50454&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=50454&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=50454&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=50454&r=mysqlcfg

« previous php.bugs (#145646) next »