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:[EMAIL PROTECTED]

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to