Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:62704 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 88618 invoked from network); 3 Sep 2012 05:03:45 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 3 Sep 2012 05:03:45 -0000 Authentication-Results: pb1.pair.com smtp.mail=laruence@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=laruence@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.220.170 as permitted sender) X-PHP-List-Original-Sender: laruence@gmail.com X-Host-Fingerprint: 209.85.220.170 mail-vc0-f170.google.com Received: from [209.85.220.170] ([209.85.220.170:41912] helo=mail-vc0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id F4/22-17065-F2A34405 for ; Mon, 03 Sep 2012 01:03:44 -0400 Received: by vcbgb30 with SMTP id gb30so5582233vcb.29 for ; Sun, 02 Sep 2012 22:03:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date :x-google-sender-auth:message-id:subject:to:cc:content-type; bh=SjNJvfspL8ootnqild6SmKx3yvw+2wha9BIq/rOrXQI=; b=NtjvlWpSoaQjK8bDu1kAPyMjSsulRfJpDt80V0dbRVBJnFgtLppra5fEuv/dkcF4wV OcZR85wY5dniMyTcb+ImORDT1EI16eoqjc7TbhKjdcDH5s1zYIunTsCvc38OXRCzNV0h zX0An1tyj9SSUT1Xk/Bt3+Cy51dtrrnj7RqXpRkKFm2eYwa1cFvXxH9llIxEq8r6CGOT 1XoA3BvyiQOb0UCERBxf0wD6Yng8WjNiXyfZS50q0vTpoldViM8Q0GlcpoGTm1o+bzEW LJbIP2KgP8/byet25qp8DG02LCICf2M8JaWaTC2XQsHhjHD7bGUEtkRh8X7ay3PO7Y0G b21g== Received: by 10.220.242.73 with SMTP id lh9mr11379647vcb.4.1346648621013; Sun, 02 Sep 2012 22:03:41 -0700 (PDT) MIME-Version: 1.0 Sender: laruence@gmail.com Received: by 10.220.18.15 with HTTP; Sun, 2 Sep 2012 22:03:20 -0700 (PDT) In-Reply-To: References: Date: Mon, 3 Sep 2012 13:03:20 +0800 X-Google-Sender-Auth: gBUDPIM_ap3lu18LxWyI-f2TpgA Message-ID: To: Anthony Ferrara Cc: internals@lists.php.net Content-Type: text/plain; charset=UTF-8 Subject: Re: [PHP-DEV] Exceptions Vs Errors From: laruence@php.net (Laruence) On Sun, Sep 2, 2012 at 9:39 AM, Anthony Ferrara wrote: > Hi all, > > There's been a lot of discussion around whether or not to include > exceptions for core (no class implementations) errors or not. There's been > a lot said on both sides. However, I'd like to pose the question from a > different angle. > > 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... > > 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 I don't have a good sulotion. but I definitely dis-agree of throwing exception anywhere.. People like me, like PHP is because it's simple, liking C . if you throw exception anywhere, then it will be a nightmare for me.. I don't care about what exact error happned, in most cases it runs well, if it failed, I can go to error log to find out why. but: try { file_put_contents(); } catch () { } try { file_put_contents(); } catch () { } try { file_put_contents(); } catch () { } ..... -1 thanks > 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)...? > > Thoughts? > > Anthony -- Laruence Xinchen Hui http://www.laruence.com/