Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:1253 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 68886 invoked from network); 5 May 2003 10:59:57 -0000 Received: from unknown (HELO tsunami4.tsunamihost.ch) (80.74.132.95) by pb1.pair.com with SMTP; 5 May 2003 10:59:57 -0000 Received: (qmail 14453 invoked from network); 5 May 2003 10:59:55 -0000 Received: from unknown (HELO dsl-217-155-231-76.zen.co.uk) (ml-daniel@lorch.cc@217.155.231.76) by tsunami4.tsunamihost.ch with SMTP; 5 May 2003 10:59:55 -0000 Date: Mon, 5 May 2003 11:59:55 +0100 To: Sterling Hughes Cc: marcus.boerger@post.rwth-aachen.de, internals@lists.php.net Message-ID: <20030505115955.39e6696a.ml-daniel@lorch.cc> In-Reply-To: <1052077704.11371.319.camel@hasele> References: <5.1.0.14.2.20030504021938.09452980@mailbox.rwth-aachen.de> <1052077704.11371.319.camel@hasele> X-Mailer: Sylpheed version 0.8.0 (GTK+ 1.2.10; powerpc-apple-darwin6.1) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] exceptions instead of errors From: ml-daniel@lorch.cc (Daniel Lorch) 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) { > 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 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