Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:45083 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 42253 invoked from network); 24 Jul 2009 17:23:11 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 24 Jul 2009 17:23:11 -0000 Authentication-Results: pb1.pair.com smtp.mail=rasmus@lerdorf.com; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=rasmus@lerdorf.com; sender-id=unknown Received-SPF: error (pb1.pair.com: domain lerdorf.com from 209.85.198.233 cause and error) X-PHP-List-Original-Sender: rasmus@lerdorf.com X-Host-Fingerprint: 209.85.198.233 rv-out-0506.google.com Received: from [209.85.198.233] ([209.85.198.233:24049] helo=rv-out-0506.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 7C/34-39659-DFDE96A4 for ; Fri, 24 Jul 2009 13:23:11 -0400 Received: by rv-out-0506.google.com with SMTP id l9so503489rvb.23 for ; Fri, 24 Jul 2009 10:23:07 -0700 (PDT) Received: by 10.140.226.6 with SMTP id y6mr2504165rvg.223.1248456187168; Fri, 24 Jul 2009 10:23:07 -0700 (PDT) Received: from trainburn-lm.corp.yahoo.com (trainburn-lm.corp.yahoo.com [207.126.233.11]) by mx.google.com with ESMTPS id k41sm3187179rvb.27.2009.07.24.10.23.05 (version=TLSv1/SSLv3 cipher=RC4-MD5); Fri, 24 Jul 2009 10:23:06 -0700 (PDT) Message-ID: <4A69EDF7.8000207@lerdorf.com> Date: Fri, 24 Jul 2009 10:23:03 -0700 User-Agent: Thunderbird 2.0.0.18 (Macintosh/20081105) MIME-Version: 1.0 To: Matt Wilson CC: Brian Moon , Ben Scholzen 'DASPRiD' , internals@lists.php.net References: <2dedb8a0907240640i118d220fte7ed4e0285aae024@mail.gmail.com> <4A69D866.9010108@moonspot.net> In-Reply-To: X-Enigmail-Version: 0.95.7 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] RFC: Replacing errors with Exceptions From: rasmus@lerdorf.com (Rasmus Lerdorf) Matt Wilson wrote: > I agree, however there are certain aspects of PHP's errors that leave a > lot to be desired. For instance, a failed fopen or a failed socket will > often result in an uncatchable warning from php. Sure, you can add a @ > to the line but that's slow and doesn't tell you anything about what > happened. > > I've been saying for years that PHP needs to get over its perl phobia > and implement something like $! > > fopen("file", "r") or throw new Exception("Error: ". $!); > > Wouldn't that be nice? I don't see the big difference between that and: if(!fopen("file", "r")) throw new Exception(); and error_get_last() gives you the type, error message, line number, and filename which you can access in your catch block. Presumably you still want to log these which you get for free so no need for the @. -Rasmus