Hi, On 21 September 2014 01:41, goat <[email protected]> wrote:
> I much prefer to do error handling with exception semantics, opposed to > checking function return values and error codes. I want to set my own php > error handler function, which converts all native php errors into thrown > exceptions. > But, I'm a bit scared to do this with code that wasn't written with this in > mind, which is probably the majority of php code. It's a huge difference in > program control flow to do this, and I fear I might break the zf2 code by > doing so. I know exceptions are used extensively throughout the zf2 code > base, but, I'm not sure it was written with the anticipation that native > php > functions would throw exceptions. > ZF2 pretty much always wraps error-spawning functions such as `fopen` or `file_get_contents` with `Zend\Stdlib\ErrorHandler` (see https://github.com/zendframework/zf2/blob/026ea4888c7d5705a1ac89aff700d4c952ebbaab/library/Zend/Stdlib/ErrorHandler.php). That turns any errors raised into exceptions that are then handled by the framework or by you. We typically avoid warnings/notices, and they make our test suite fail as well. > Is it common to do this in zend 2? Have people had a good experience with > it? > Yes, we simply don't use user-level errors, only exceptions. There are few cases where this is not true, but that's because you should fix your code in those particular cases. > ps - I'm also using the BjyAuthorize module. > BjyAuthorize should be error-free (only exceptions). Marco Pivetta http://twitter.com/Ocramius http://ocramius.github.com/
