On Thu, Jun 21, 2012 at 2:59 AM, Sebastian Krebs <krebs....@googlemail.com> wrote: > 2012/6/20 Michael Morris <dmgx.mich...@gmail.com> > >> [/snip] >> >> An example for additional clarity. >> >> set_exception_handler(function ($e) { >> echo $e->getMessage(); >> // Don't know if this is correct - but should be able to illustrate here >> if ($e->getCode() == E_NOTICE & E_STRICT) { >> resume null; >> } >> >> echo 'Dying now'; exit; >> }); >> >> throw new Exception('A test', E_NOTICE); >> >> echo "We didn't die"; >> >> The code above when run would echo "A test. We didn't die."; >> >> >> > Whats about > > $user = $this->getUser(); // Throws exception > echo $user->getName(); > > > Now the second one will fail too, but in reality it shouldn't even get > executed... > > Regards, > Sebastian > >
Then the error handler shouldn't have called resume. The error handler should only call the keyword if its safe to do so. And now that I think about it, not having the ability to return anything would be for the best since it would keep the usefulness of this to a minimum and avoid magic headaches. Cause the last thing we need is for people to start using the exception handling mechanism as additional control structure tree. What about what I'd mentioned before that this would allow? With this in place the existing PHP Errors could all be converted to Exceptions. The default exception handler would resume after catching any low level exceptions (E_NOTICE, E_WARNING, etc) but a custom one can be free to do whatever. Unifying the mechanisms also would allow for exceptions for other fatal events. This would be highly useful. try { require( 'path/to/file.php' ); } catch ( PARSE_EXCEPTION $e ) { // some logging then pretty death } Most of the time you'd never want to resume after such an exception.... Most of the time. In any event "resume" would allow PHP to get back to having only one exception mechanism instead of two since the behavior of errors could be emulated under exceptions. That is the principle boon of resume. Does that balance the two drawbacks 1) It's a new keyword, so BC breaks occur with code that used it as a function name. 2) The spaghetti possibilities increase. -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php