Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:62025 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 20394 invoked from network); 3 Aug 2012 22:47:29 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 3 Aug 2012 22:47:29 -0000 Authentication-Results: pb1.pair.com smtp.mail=nikita.ppv@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=nikita.ppv@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.217.170 as permitted sender) X-PHP-List-Original-Sender: nikita.ppv@gmail.com X-Host-Fingerprint: 209.85.217.170 mail-lb0-f170.google.com Received: from [209.85.217.170] ([209.85.217.170:46352] helo=mail-lb0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 9C/55-23476-0055C105 for ; Fri, 03 Aug 2012 18:47:29 -0400 Received: by lbgc1 with SMTP id c1so2043793lbg.29 for ; Fri, 03 Aug 2012 15:47:26 -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=Dg/0pQlxkZGqn6giSgXY3s/4vK25yx7J9C2dTFGJzTE=; b=k8+pa4XuWZZGpeegde/7/RZwQPxaypzLB28r+TBa+JhcLQ1R76A53CZKjCbZfZUgt6 2lc3JbdJk+lZUjgXdHSm4hTHLr+BusWOBpMsICndxyu+Xji3oU45iK9XsE2oON8Fng/M JItLKZbZyKhvmR4zi7qC3ImpxQv93Bit8f02PGlDzXF9dPK1k/4s0NnU7jh4mJgTngwe kCR5c8vThFuCqaKJSBbqvptoZmXnSHTcrWYrA5oBUnYQAC7lzTZZ4Kia5an8Ws8oXHq6 BlP2wXkqU0iynq8Oi5/JSP98tlEr3vrFOC3Pc2w/7YuNsVTkH3tq1jZ5CLBSONh64fuE /X/g== MIME-Version: 1.0 Received: by 10.112.43.98 with SMTP id v2mr1294019lbl.1.1344034045925; Fri, 03 Aug 2012 15:47:25 -0700 (PDT) Received: by 10.152.114.70 with HTTP; Fri, 3 Aug 2012 15:47:25 -0700 (PDT) In-Reply-To: References: Date: Sat, 4 Aug 2012 00:47:25 +0200 Message-ID: To: Ferenc Kovacs Cc: PHP Internals , Andrew Faulds , Stan Vass , Etienne Kneuss Content-Type: text/plain; charset=ISO-8859-1 Subject: Re: [PHP-DEV] Error handling brainstorming From: nikita.ppv@gmail.com (Nikita Popov) On Fri, Aug 3, 2012 at 10:55 PM, Ferenc Kovacs wrote: > Hi, > > We started a discussion about the current error handling mechanism and the > possible improvements in the "Why do disabled functions / classes generate > a WARNING" thread[1], but that is a little bit offtopic there, so I decided > to create a separate thread for it. I think there are several types of errors in PHP that have to be handled differently: * There are "debugging" class errors, like notices etc. They are normally programming mistakes, but don't really prevent further execution of the script. Those should stay as they are. Throwing exceptions here would make things more complicated for the caller. * There are real errors, which should actually stop execution, but which currently don't because throwing a fatal error would be overkill due to it's incatchability (and even recoverable fatals are hard to catch). Many warnings fall into this category. E.g. if a function is called with incorrect parameters (e.g. too little of them) then an E_WARNING is thrown. The wrong function call is clearly an error, but PHP chooses to continue execution there. In my eyes this is a mistake and these cases should be exceptions. (As exceptions are easily catchable one can combine the best of both worlds here). * There is a small number of recoverable fatal errors. Those are obviously the clearest candidates for exceptions, because recoverable fatal *is* basically an exception with very ugly catching. * There are a large number of fatal errors in places which aren't really fatal. They probably should be recoverable fatals now, and as such exceptions in the future. * There is a small number of truly fatal errors, i.e. some kind of problem deep in the engine. There is probably no way to turn those into exceptions. * Another special category are parse and compilations errors. Those are not inherently fatal (e.g. a parse error in an eval() does not have to stop script execution), but they would be really hard to turn into exceptions with the current architecture. To summarize, what I'd like to see: * Not-really fatal errors (and currently recoverable fatal errors) to be converted into exceptions * Some of the warnings be converted to exceptions (depends on the exact context). * Leave notices etc alone. Nikita