Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:1274 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 56329 invoked by uid 1007); 5 May 2003 15:48:24 -0000 Message-ID: <20030505154824.56328.qmail@pb1.pair.com> To: internals@lists.php.net Date: Tue, 06 May 2003 01:48:59 +1000 User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.2.1) Gecko/20021130 X-Accept-Language: en-us, en MIME-Version: 1.0 References: <5.1.0.14.2.20030504021938.09452980@mailbox.rwth-aachen.de> <1052077704.11371.319.camel@hasele> <20030505115955.39e6696a.ml-daniel@lorch.cc> In-Reply-To: <20030505115955.39e6696a.ml-daniel@lorch.cc> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Posted-By: 203.37.117.98 Subject: Re: [PHP-DEV] exceptions instead of errors From: tk.lists@fastmail.fm (Terence) some questions Daniel Lorch wrote: > hi, > > >>Just a note that I'd really like to see this. One of the great things >>about exceptions will be: >> >>try { >> $m = mysql_connect("localhost", "user", "pass"); >> $sth = mysql_query("select bar from foo", $m); >> while ($row = mysql_fetch_array($sth)) { >> echo $row[0]; >> } >> mysql_close($m); >>} catch (exception $e) { Is "exception" class built in? if so, extendable by users? if not, how does getMessage() know where to find the error - especially if this error is produced by an extension. >> echo $e->getMessage(); >>} >> >>This allows you to remove all the nasty if ($conn) could, and move your >>error handling into a singular place. [..] > > > Read more here: > > http://java.sun.com/docs/books/tutorial/essential/exceptions/definition.html > And reading the article, one can see that it relys on types to bubble up and be cought correctly. > Basically try/catch-statements allow you to keep the main code block short > and readable because the error handling code is moved somewhere else. Would > be nice seeing this in PHP. > > -daniel