Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:62021 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 13793 invoked from network); 3 Aug 2012 21:44:50 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 3 Aug 2012 21:44:50 -0000 Authentication-Results: pb1.pair.com smtp.mail=tyra3l@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=tyra3l@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: tyra3l@gmail.com X-Host-Fingerprint: 209.85.220.170 mail-vc0-f170.google.com Received: from [209.85.220.170] ([209.85.220.170:41308] helo=mail-vc0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id D7/04-23476-2564C105 for ; Fri, 03 Aug 2012 17:44:50 -0400 Received: by vcbgb30 with SMTP id gb30so1358716vcb.29 for ; Fri, 03 Aug 2012 14:44:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=Clm7f/pO5puug8JJ7qKnMgSB+LMjbMQs9yyPzOlSCxk=; b=m0Xwg/MCjH8vbLoNrDDbASLDtnpPj02yVs+dYdMx1/VZld2ggEMOWT1mTNRYFL70pm jdPd1r+xK77p5eXoDkLusG4R6NYZEylCXAfO3wT3eAyZGRRnzplKvg0cgP+xzci33cQk 3k49aUxEX4T335vzvl+zNsfeVvD7Eq4uTYzZS22BIepIb+sLJ6/lgDzyeGv44G8Z1NZQ xMnQQibhKmlT5g/ohyG0/nFrn2PRC/tVlQjTxKaCkaIMqLuEbpaLzY32Du0v6+AtjegW CZ3ODff8DPLANa7ddI34J8KXqB1sn/zYXbEFO63ZR/bQ3yCL2wtvir9mocP0Xjub+s6A i5FA== MIME-Version: 1.0 Received: by 10.52.100.4 with SMTP id eu4mr2172034vdb.66.1344030286559; Fri, 03 Aug 2012 14:44:46 -0700 (PDT) Received: by 10.58.216.166 with HTTP; Fri, 3 Aug 2012 14:44:46 -0700 (PDT) In-Reply-To: <501C3D0D.8050904@ajf.me> References: <501C3D0D.8050904@ajf.me> Date: Fri, 3 Aug 2012 23:44:46 +0200 Message-ID: To: Andrew Faulds Cc: PHP Internals , Stan Vass , Etienne Kneuss Content-Type: multipart/alternative; boundary=20cf3071c710cc3b6404c6636f3c Subject: Re: Error handling brainstorming From: tyra3l@gmail.com (Ferenc Kovacs) --20cf3071c710cc3b6404c6636f3c Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On Fri, Aug 3, 2012 at 11:05 PM, Andrew Faulds wrote: > On 03/08/12 21:55, Ferenc Kovacs wrote: > > Andrew: > From your mails, it seems that you don't agree with Stan on turning > everything but fatals into exceptions[9]. > I'm really confused about that, as if we take away warnings (and by that > logic everything else which is less serious than a warning) the we would > only have the fatal errors (which we already discussed to not turn into > exceptions and you also seemed to agree[10]), E_USER > and E_RECOVERABLE_ERROR. > Is this what you propose? > > Warnings aren't "errors" as such (IMO they are little more than glorified > debugging print statements). Making them into exceptions would mean you'd > have to catch them, whilst at the moment they are loud but harmless. > errors and warnings/notices/etc. share the same infrastructure(called error handling. :P) so it is a little bit easy to get confused when someone talks about error handling in generals by errors, or only just a subset of the error levels. > However, I think more serious errors should be exceptions. But perhaps in > PHP 6, because obviously this would break a lot of things. > okay, then it is clear. > > > My opinion (and this is what I tried to explain to you) is that it is > pretty common in the core and the bundled extensions to raise notices and > warnings left and right, and still do something, > > By that I thought you meant errors of the kind E_STRICT, not warnings. > Misunderstanding. > I was referring to notices/warnings, sorry for the confusion. But it seems from your reply that you take E_STRICT messages as errors? Why? Those can only happen on successful operations, and until 5.4, they weren't part of E_ALL, so they are the less known and less serious of all of the error levels. > > If we would turn anything less serious than E_RECOVERABLE_ERROR (so any > notice, deprecation notice, strict notice or warning)into an exception, > that would be a huuuuuuge BC break. > > Of course. I think they are something the current errors system should > remain for. It should be for that kind of thing, but proper "errors" (you > know, things going wrong, not warnings etc.) should be exceptions, I thin= k. > Yeah, errors are meant to be explicit, hard to not notice/handle and for that description, Exceptions works just fine. > > Basically silecing errors through setting error_reporting level, custom > error handlers or the @ operator would stop working, and one should put > everything into a try-catch block to not have his code blown into his cod= e > constantly. > > Another thing that I mentioned: even if you catch everything, there > would be some things that you couldn't do anymore. > Any method which throws notices or strict/deprecated notices or warnings > would be broken, as the execution would be halted (as the execution jumps > into the catch) which would be a major PITA to the userland developers, a= nd > without further work, it could make the userland/engine in a more fragile > state, as the original call was interrupted but the execution still > continues from a different spot. > With the current error handling the execution either resumes after the > error handler is called, or the execution is terminates gracefully > > The current error handling provides a way to trigger multiple > errors/warnings for an operation, and allows to still return and continue > the execution. > Turning everything into exceptions would kill both of those, and without > providing something similar suite, we can't do that imo. > > So basically these are our boundaries: > > - Fatal errors can't be turned into Exceptions, but it was mentioned > multiple times, that there are some fatals, which could be turned into > E_RECOVERABLE_ERROR. > > Truly fatal errors can't become exceptions. But some fatal errors > shouldn't be fatal and are recoverable (and I think these should become > exceptions). > yeah, this is in line with what I said. ... skip the links ... To sum up my thoughts: > - "real" (i.e., things going wrong, code doing something bad) errors > should become exceptions, with the possible exception of fatal errors tha= t > it is impossible to recover from > I think that is the further where can we go without breaking every code out there. > - notices, warnings, deprecations, etc. should stay as PHP errors, so you > can just suppress them if you want, and they don't require you to handle > them > I'm thinking about some kind of new infrastructure which would allow the developer to handle/fetch the errors locally (similar to how you can fetch the last error with error_get_last(), but with the ability to fetch multiple items and only those which were generated for a given piece of code. of course we could still keep the set_error_handler() as I see two different use case for handling warnings: 1. you want to log all errors in some other format what the log_errors and error_log ini directives provide 2. you want to get the errors/warnings in the same scope where the error occured and you want to handle that error in that context for 1, the current set_error_handler is perfect (maybe some improvements would be welcome, like having multiple handlers at the same time as we allow it for spl_autoload_register, etc.), for 2, it would be nice having a better infrastructure, currently it isn't as easy to fetch the warnings for a specific operation as it could be. > So fatal errors and notices/warnings/deprecations stay errors, everything > else becomes an exception. > > Clear? > yep. ps: in the meantime we discussed with you on IRC, and it seems that after that, you would also put E_STRICT to the warnings group. --=20 Ferenc Kov=C3=A1cs @Tyr43l - http://tyrael.hu --20cf3071c710cc3b6404c6636f3c--