Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:87813 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 81008 invoked from network); 19 Aug 2015 19:16:29 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 19 Aug 2015 19:16:29 -0000 Authentication-Results: pb1.pair.com header.from=ircmaxell@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=ircmaxell@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.215.45 as permitted sender) X-PHP-List-Original-Sender: ircmaxell@gmail.com X-Host-Fingerprint: 209.85.215.45 mail-la0-f45.google.com Received: from [209.85.215.45] ([209.85.215.45:35154] helo=mail-la0-f45.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 8D/72-56231-B06D4D55 for ; Wed, 19 Aug 2015 15:16:29 -0400 Received: by lahi9 with SMTP id i9so9195106lah.2 for ; Wed, 19 Aug 2015 12:16:24 -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=+9UFN2vygjxEODRvGQkLPOuoUXFh/9EuS6D0nn8m90o=; b=VdfXHgZjYD6gBUVhTQ0wEzjxcZTlRVRG3QRfPHSIgLr7e/2nggOjZws84j2Vsj+o94 yqGSqxzmzD/pk2+4jch2gQSrncS38+rlARbRkZBup7eze0fwUifAfx0w+k1zMDW/MWXG a28pSrM2yb5U8P56WU2q/T4jbDzC3Y9GT8GU7u8jYR1hk4ZyYGuqs0Dw5NSdFXAf8E+U 9PadLc4CH1dcmy6zXhs6smBluBmKbsPJ+hCefnD277MlYuEW7fpUDvMfskjlyiFnnFzg Z5Lp9dx1ghmyt38wULAZv8+D6ZiUY2ON6wpWraM1ukHwJqn0HbU2jgObAeXAnpffkc5Z zIfQ== MIME-Version: 1.0 X-Received: by 10.112.156.137 with SMTP id we9mr9796646lbb.110.1440011784476; Wed, 19 Aug 2015 12:16:24 -0700 (PDT) Received: by 10.25.141.131 with HTTP; Wed, 19 Aug 2015 12:16:24 -0700 (PDT) In-Reply-To: <55D4CED2.4090201@gmail.com> References: <20150817123142.13418f26@csystems> <20150817131900.66906015@csystems> <55D4CED2.4090201@gmail.com> Date: Wed, 19 Aug 2015 15:16:24 -0400 Message-ID: To: Stanislav Malyshev Cc: Derick Rethans , Christian Weiske , Niklas Keller , PHP Internals Content-Type: text/plain; charset=UTF-8 Subject: Re: [PHP-DEV] set_exception_handler catches all Throwables From: ircmaxell@gmail.com (Anthony Ferrara) Stas and all, On Wed, Aug 19, 2015 at 2:45 PM, Stanislav Malyshev wrote: > Hi! > >> Actually, I don't call this intended. This is just as much as a BC break >> as the original implementation where Errors where also Exceptions. IMO, >> set_exception_handler() should be changed - with my preference it not >> capturing Error, and instead have an additional set_throwable_handler(). > > Could you explain why? As I understand, set_exception_handler() is > needed to provide a backstop for the cases when all else fails and allow > for ordered shutdown, nice error message, logging, etc. With this in > mind, catching all Throwable's is well within this function. So what > would be the case for having two separate functions for this task and > what would be the case for using one that only catches half of the > runaway exceptions (throwables) but not the other half? This is a very important point that bears repeating. The difference is that if an exception handler is called, the script *will* terminate after the handler is called. The point in separating catch(exception) from catch(throwable) was that the prior can be done in specific circumstances where the only reason an exception was thrown was because of a specific failure (which could be worked around). Adding throwables changes that contract, and hence was made to not inherit from Exception. But this case, the exception handler should purely be a logging / pretty error to user. This isn't a "best practice" distinction either because since execution terminates afterwards there isn't much you can do (you can't even call the exception handler again). So in this case, I don't really see the distinction here that would warrant splitting it into separate functions. If it was like error_handler where you could return false and resume, I'd be 100% on board. But as it is today, I don't see why separating it would be beneficial (what's the use-case where you need to split it). Anthony