Re: Error handling brainstorming
| From: | Ralf Lang | Date: | Thu, 09 Aug 2012 08:43:38 +0000 |
| Subject: | Re: Error handling brainstorming | ||
| References: | 1 2 3 4 5 6 7 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-62099@lists.php.net to get a copy of this message | ||
> I know PHP's model is all messed up, but no one here, I believe, is
> asking about putting non-error log messages in Exceptions. IO failure is
> an exception.
>
> If your IO operation fails, you can't just log it and plow forward
> blissfully without handling the problem.
>
> Stan
>
Exceptions allow you to decide:
I know how to handle it -> deal with it,
I don't know how to handle it -> pop up to higher layer who might know
I didn't know this case needs to be handled -> pop up to handler of last
resort, either crash or catch-all and at least present some meaningful
info on what happened.
That's managable. Of course you can probably do most stuff with error
code handling, PEAR_Error & Friends, error handlers for really bad
stuff. We've been doing this before Exceptions. But wherever it makes
sense, I tend to use them.