Re:PHP Hacking aka trying to push PHP internals forwards
by wvenable on Friday June 10, 2011 @12:14PM
(#2641376)
PHP already provides a mechanism to replace errors with exceptions (set_error_handler() and the ErrorException exception type). I do this on all my projects.
[ Parent
| on HN ]
Re:PHP Hacking aka trying to push PHP internals forwards
by jcoby on Friday June 10, 2011 @12:27PM
(#2641428)
I'm aware of that method. It's not an ideal approach IMO.
Specific errors should throw specific exceptions. That way I can handle the ones I know how to handle and let the others bubble up and either completely break the app to be logged and fixed later or get handled correctly somewhere else. With ErrorException, you have to look at the contents of the error message to see if it's an error you can handle or need to rethrow.
Re:PHP Hacking aka trying to push PHP internals forwards
by wvenable on Friday June 10, 2011 @12:53PM
(#2641527)
If something in PHP triggers an error, there is very little to recover from. It's either a developer error or an unrecoverable problem (a file expected to exist was not found, network is down, etc). In any of my projects, I've never needed to recover from PHP ErrorException.