Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:5314 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 10884 invoked by uid 1010); 7 Nov 2003 16:17:48 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 10860 invoked from network); 7 Nov 2003 16:17:48 -0000 Received: from unknown (HELO shiva.mind.de) (212.42.230.204) by pb1.pair.com with SMTP; 7 Nov 2003 16:17:48 -0000 Received: from [80.142.156.91] (p508E9C5B.dip.t-dialin.net [80.142.156.91]) by shiva.mind.de (Postfix) with ESMTP id 4C5AA97C6B; Fri, 7 Nov 2003 17:17:42 +0100 (CET) Date: Fri, 7 Nov 2003 17:17:45 +0100 Reply-To: =?ISO-8859-1?B?TWFyY3VzIEL2cmdlcg==?= X-Priority: 3 (Normal) Message-ID: <14150734546.20031107171745@marcus-boerger.de> To: "Cristiano Duarte" Cc: internals@lists.php.net In-Reply-To: <20031107151506.16985.qmail@pb1.pair.com> References: <20031024200902.90818.qmail@pb1.pair.com> <5.1.0.14.2.20031031010103.03db8bd0@127.0.0.1> <20031107151506.16985.qmail@pb1.pair.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit Subject: Re: [PHP-DEV] Re: finally again From: helly@php.net (=?ISO-8859-1?B?TWFyY3VzIEL2cmdlcg==?=) 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