Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:91562 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 4972 invoked from network); 9 Mar 2016 01:47:47 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 9 Mar 2016 01:47:47 -0000 Authentication-Results: pb1.pair.com header.from=pierrick@webstart.fr; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=pierrick@webstart.fr; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain webstart.fr from 209.85.160.179 cause and error) X-PHP-List-Original-Sender: pierrick@webstart.fr X-Host-Fingerprint: 209.85.160.179 mail-yk0-f179.google.com Received: from [209.85.160.179] ([209.85.160.179:35095] helo=mail-yk0-f179.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 71/C3-15119-2C08FD65 for ; Tue, 08 Mar 2016 20:47:47 -0500 Received: by mail-yk0-f179.google.com with SMTP id y66so14549528ykd.2 for ; Tue, 08 Mar 2016 17:47:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=webstart-fr.20150623.gappssmtp.com; s=20150623; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:cc; bh=CK9EqGqQlnZbcRiQ3Rh0228xUfiWFVWBsxZqixGQuLA=; b=KohXHmOJUsLyS4SD3FhnLcZkZ01uL9BENvIFpCQ74+egHj9NWPHX/ns2F87ZrTTfqR qtGE3tA+Gjgf7CXDzAe2asbYfk7uGuZYJK6YMhl8UIouis008OzET8x+T2xb0VMmwbrz KeIPzb1K5kba9vlT2CTq8zDlZ9RDniy89fxadgopj5gohcBxuHNrobFbEjzYbqmj4MqY 1odJmRw51SFPwvB+TRZpQzHnaTyfBtvdL9gliP9UezrArm3cXcYEqox5wj1jClTcvoXG njJqKkx7wdS39SPGYMgFVzWbkaRVIHt6sz/CttiiKfEisHVlvodEvGx2oiUBMfFmqkQM fpdw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:sender:in-reply-to:references:date :message-id:subject:from:to:cc; bh=CK9EqGqQlnZbcRiQ3Rh0228xUfiWFVWBsxZqixGQuLA=; b=LU5CyydrJfnrBVy3i4ba2Cg0e3Fj6nq8jcAT0ixpfiW7tzuQMQX+kM01aMik/D2fJa J9HjdBMP+EUT/TW6XmW2LboIbbKI31DN4HdQseNSccRZGOaL9HkmSxvP1B5xQ+D0XTzL vTWBkKkj2HqZ2Wt9QMe5v932q29gTfv/FM3+uhcxR9wjPZ4AWO2SrxEoFi5sNmArPCk1 W9QAp2tqcA7SWwmLbFuCO2DyWjeBIFmpCGNOP2cTeTv9dLIN/UBUnchCCYXzJTIcEWCv RPysa2VXeysIHuO0wSxeatFxfQ2bjQfIBrmN48jR7nbfN4ZoxlIqqzt/H2QQS9dV4c+/ 2d3g== X-Gm-Message-State: AD7BkJJZ9BjexlF90asZWiXcodkVoZmVboFPzZrQfgOMPkt6gjUu2TNywxQMNGtMirdw1LfcJ2wzYQzrwceGMA== MIME-Version: 1.0 X-Received: by 10.37.43.87 with SMTP id r84mr18302010ybr.105.1457488063805; Tue, 08 Mar 2016 17:47:43 -0800 (PST) Sender: pierrick@webstart.fr Received: by 10.37.76.130 with HTTP; Tue, 8 Mar 2016 17:47:43 -0800 (PST) In-Reply-To: <56DF5B04.1080505@telia.com> References: <56DF5B04.1080505@telia.com> Date: Tue, 8 Mar 2016 20:47:43 -0500 X-Google-Sender-Auth: gr4VE_wMDPyGW46LKNBtRweh0gM Message-ID: To: =?UTF-8?Q?Bj=C3=B6rn_Larsson?= Cc: =?UTF-8?B?QnJvbmlzxYJhdyBCaWHFgmVr?= , PHP internals Content-Type: multipart/alternative; boundary=001a11352f8a4ef58a052d93e286 Subject: Re: [PHP-DEV] [RFC Discussion] Catching multiple exception types From: pierrick@adoy.net (Pierrick Charron) --001a11352f8a4ef58a052d93e286 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Hi Bj=C3=B6rn, The only time I had to do this with core PHP exceptions is to make the code compatible for both PHP5 and PHP7: try { } catch(\Exceptions $e) { } catch(\Throwable $e) { } But it will of course not be applicable since this feature is targeting PHP7.1. Other than that the PHP core exception hierarchy is well enough for MY needs. But if someone already had to do this fill free to provide your use case as an example. My main target is custom exceptions (even if the logic is applicable on everything Throwable). A custom exception use case would be some method that throw thwo different kind of exceptions like for example the doctrine AbstractQuery::getSingleResult (NoResultException, NonUniqueResultException) that you could want to handle the same way. An other really easy example would be simple code like this one that I found in symfony (not really a big deal but still) } catch (AccessException $e) { return false; } catch (UnexpectedTypeException $e) { return false; } And other piece of code using multiple libraries. On 8 March 2016 at 18:06, Bj=C3=B6rn Larsson wr= ote: > Den 2016-03-08 kl. 22:42, skrev Pierrick Charron: > >> Hi internals, >> >> Bronis=C5=82aw Bia=C5=82ek and I would like to start a discussion about = allowing >> multiple exception types to be caught in a single catch statement. >> >> https://wiki.php.net/rfc/multiple-catch >> >> A working implementation and tests are available in the RFC. >> >> We are waiting for your constructive feedback and thoughts. >> >> Thanks >> Pierrick >> >> Nice RFC! Think it would be good if you had an example in the > RFC showing the applicability of catching two php exceptions. > Especially given the new exception hierarchy in PHP 7. I'm also > pondering if the main target for this is custom exceptions or > the built-in ones or both? > > Regards //Bj=C3=B6rn Larsson > > PS > --001a11352f8a4ef58a052d93e286--