Stas and all, On Wed, Aug 19, 2015 at 2:45 PM, Stanislav Malyshev <smalys...@gmail.com> wrote: > Hi! > >> Actually, I don't call this intended. This is just as much as a BC break >> as the original implementation where Errors where also Exceptions. IMO, >> set_exception_handler() should be changed - with my preference it not >> capturing Error, and instead have an additional set_throwable_handler(). > > Could you explain why? As I understand, set_exception_handler() is > needed to provide a backstop for the cases when all else fails and allow > for ordered shutdown, nice error message, logging, etc. With this in > mind, catching all Throwable's is well within this function. So what > would be the case for having two separate functions for this task and > what would be the case for using one that only catches half of the > runaway exceptions (throwables) but not the other half?
This is a very important point that bears repeating. The difference is that if an exception handler is called, the script *will* terminate after the handler is called. The point in separating catch(exception) from catch(throwable) was that the prior can be done in specific circumstances where the only reason an exception was thrown was because of a specific failure (which could be worked around). Adding throwables changes that contract, and hence was made to not inherit from Exception. But this case, the exception handler should purely be a logging / pretty error to user. This isn't a "best practice" distinction either because since execution terminates afterwards there isn't much you can do (you can't even call the exception handler again). So in this case, I don't really see the distinction here that would warrant splitting it into separate functions. If it was like error_handler where you could return false and resume, I'd be 100% on board. But as it is today, I don't see why separating it would be beneficial (what's the use-case where you need to split it). Anthony -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php