Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:62660 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 36232 invoked from network); 2 Sep 2012 08:37:20 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 2 Sep 2012 08:37:20 -0000 Authentication-Results: pb1.pair.com header.from=ajf@ajf.me; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=ajf@ajf.me; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain ajf.me designates 64.22.89.133 as permitted sender) X-PHP-List-Original-Sender: ajf@ajf.me X-Host-Fingerprint: 64.22.89.133 oxmail.registrar-servers.com Received: from [64.22.89.133] ([64.22.89.133:33191] helo=oxmail.registrar-servers.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 60/44-17065-EBA13405 for ; Sun, 02 Sep 2012 04:37:18 -0400 Received: from [192.168.0.200] (5ad3285b.bb.sky.com [90.211.40.91]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by oxmail.registrar-servers.com (Postfix) with ESMTPSA id 3774475808B; Sun, 2 Sep 2012 04:37:15 -0400 (EDT) Message-ID: <50431A98.6020101@ajf.me> Date: Sun, 02 Sep 2012 09:36:40 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:14.0) Gecko/20120714 Thunderbird/14.0 MIME-Version: 1.0 To: Anthony Ferrara CC: internals@lists.php.net References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Exceptions Vs Errors From: ajf@ajf.me (Andrew Faulds) On 02/09/12 02:39, Anthony Ferrara wrote: > Right now, I see the biggest problem with errors currently in PHP is that > there's no easy way of discerning between error types to be able to handle > them. Therefore it's easier to ignore the error than it is to handle it > bluntly. For example, I may want to distinguish between failure modes of > file_put_contents(). Right now, three types of errors can occur: File not > writable (can't open it), Can't write to file (write failed), and Partial > write only (but certain bytes were written). > http://lxr.php.net/xref/PHP_5_4/ext/standard/file.c#661 Right now, there's > no way short of parsing the error string to even attempt to distinguish > between them (arguably the first two could be treated the same, but the > third could lead to very dangerous situations). Which is non-trivial to say > the least... Isn't one of the main points of using Exceptions that you can catch all exceptions (Exception) or subclasses (hypothetical IOException, etc.) or very specific ones (hypothetical IOFileOpenException)? > > So, while I know there's some discontent about having the core raise > exceptions, let me ask the question differently: > > Without moving to exceptions, how could the current error and error > handling mechanisms be improved to make the scenario I posted above easier. > To make handling errors just as easy as ignoring them (or preferably > easier)...? I don't wish to derail this thread from the get-go, but what's your opposition to moving to exceptions? -- Andrew Faulds http://ajf.me/