Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:62662 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 39378 invoked from network); 2 Sep 2012 08:55:25 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 2 Sep 2012 08:55:25 -0000 Authentication-Results: pb1.pair.com smtp.mail=glopes@nebm.ist.utl.pt; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=glopes@nebm.ist.utl.pt; sender-id=unknown Received-SPF: error (pb1.pair.com: domain nebm.ist.utl.pt from 193.136.128.22 cause and error) X-PHP-List-Original-Sender: glopes@nebm.ist.utl.pt X-Host-Fingerprint: 193.136.128.22 smtp2.ist.utl.pt Linux 2.6 Received: from [193.136.128.22] ([193.136.128.22:53171] helo=smtp2.ist.utl.pt) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 50/E4-17065-BFE13405 for ; Sun, 02 Sep 2012 04:55:25 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp2.ist.utl.pt (Postfix) with ESMTP id 8F8EE70003D3; Sun, 2 Sep 2012 09:55:20 +0100 (WEST) X-Virus-Scanned: by amavisd-new-2.6.4 (20090625) (Debian) at ist.utl.pt Received: from smtp2.ist.utl.pt ([127.0.0.1]) by localhost (smtp2.ist.utl.pt [127.0.0.1]) (amavisd-new, port 10025) with LMTP id ixGhUux9G6Gj; Sun, 2 Sep 2012 09:55:20 +0100 (WEST) Received: from mail2.ist.utl.pt (mail.ist.utl.pt [IPv6:2001:690:2100:1::8]) by smtp2.ist.utl.pt (Postfix) with ESMTP id 3E063700044D; Sun, 2 Sep 2012 09:55:20 +0100 (WEST) Received: from damnation.nl.lo.geleia.net (unknown [IPv6:2001:470:94a2:4:21d:baff:feee:cc0b]) (Authenticated sender: ist155741) by mail2.ist.utl.pt (Postfix) with ESMTPSA id 640BF200C812; Sun, 2 Sep 2012 09:55:19 +0100 (WEST) Content-Type: text/plain; charset=utf-8; format=flowed; delsp=yes To: internals@lists.php.net, "Anthony Ferrara" References: Date: Sun, 02 Sep 2012 10:55:36 +0200 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Organization: =?utf-8?Q?N=C3=BAcleo_de_Eng=2E_Biom=C3=A9di?= =?utf-8?Q?ca_do_I=2ES=2ET=2E?= Message-ID: In-Reply-To: User-Agent: Opera Mail/12.01 (Linux) Subject: Re: [PHP-DEV] Exceptions Vs Errors From: glopes@nebm.ist.utl.pt ("Gustavo Lopes") On Sun, 02 Sep 2012 03:39:15 +0200, Anthony Ferrara wrote: > 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. I don't think your specific scenario needs to be improved. file_put_contents() is a high level function with coarse error reporting. If you need to distinguish the problems, you can open the files separately, and use stream_copy_to_stream(). But in any case, for the general problem you're raising -- that false does not give enough information for handling the error, the solution is well-established: you have some way of getting the error code. This can be done either through a dedicated function (like curl_errno, mysqli_errno) or through extra parameters, like it's done in stream_socket_client(). And yes, it's unfortunate we don't have any sort of common interface or even consistency in this area. > To make handling errors just as easy as ignoring them (or preferably > easier)...? I don't think that's feasible, except maybe by using checked exceptions (which most people hate, with good reason). Writing bad exception-based code and bad error-code-based code is always easy. See the tables here: http://blogs.msdn.com/b/oldnewthing/archive/2005/01/14/352949.aspx -- Gustavo Lopes