Re: Re: finally again
| From: | Marcus Börger | Date: | Fri, 07 Nov 2003 16:17:45 +0000 |
| Subject: | Re: Re: finally again | ||
| References: | 1 2 3 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-5314@lists.php.net to get a copy of this message | ||
Hello Cristiano,
Friday, November 7, 2003, 4:15:06 PM, you wrote:
> Hi Andi,
>> I've stated my opinion in the past (search the archives) and I don't think
>> it'd be feasible (nor critical) to implement this...
> Do you agree that if we don't have finally we should have a way to catch all exceptions ?
> Let me explain:
> If you have a library that can raise a huge number of different
> exceptions and you don't have finally, you should treat all exceptions at
> the same try/catch block, and rethrow the exceptions that should propagate.
> If you have finally, you can treat just the exceptions you need and
> leave the others to be treated by the caller.
> For example: if you don't have finally, don't have a "catch-all" clause
> and lock some resouce inside a try block, you need to unlock it:
> 1) in the try block: before every return statement after the resource allocation
> 2) write a catch block for all possible exceptions that could be
> raised and put the code before every return/throw statement (this could be
> dozens of times)
> 3) at the end of the try/catch block
> If you have finally, you just put the same code inside the finally
> block. No need to catch every exceptions one-by-one, no need to rethrow
> exceptions that shouldn't be caught, no need to make code redundancy...
> I know it's not critical, but IMHO it's important. I hope I was clear enough... :-)
Regarding catch all the current idea of most developers i spoke to on the
conf was that every exception should inherit from the buildin class
exception. And therefor a simple catch(Exception $e) would do the trick.
--
Best regards,
Marcus mailto:helly@php.net