Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:91583 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 60564 invoked from network); 9 Mar 2016 12:04:55 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 9 Mar 2016 12:04:55 -0000 Authentication-Results: pb1.pair.com header.from=me@kelunik.com; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=me@kelunik.com; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain kelunik.com from 81.169.146.217 cause and error) X-PHP-List-Original-Sender: me@kelunik.com X-Host-Fingerprint: 81.169.146.217 mo4-p00-ob.smtp.rzone.de Received: from [81.169.146.217] ([81.169.146.217:45323] helo=mo4-p00-ob.smtp.rzone.de) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id A3/51-53667-56110E65 for ; Wed, 09 Mar 2016 07:04:54 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1457525091; l=3943; s=domk; d=kelunik.com; h=Content-Type:Cc:To:From:Subject:Date:References:In-Reply-To: MIME-Version; bh=6NUwRBoN+9zaw7E92OvhDj9K6+yMV2yMyD4SPQ7Cca4=; b=egwgL7TLKcFva1V88Se37jLDpjbrI5SOXsr9x4HjI7w8toLnxEs52Cwr8jPMVe5+UWi +qh+6h1r1JgPMii771xYTFYqyaWoynan4FcO23sd6yK3Sb7m8DvCv3vZ/1E9Cmq4/jemq 1E3ol7D4NiT999svI/UNylr+uvYB0zO/3+M= X-RZG-AUTH: :IWkkfkWkbvHsXQGmRYmUo9mls2vWuiu+7SLGvomb4bl9EfHtO3U6 X-RZG-CLASS-ID: mo00 Received: from mail-wm0-f46.google.com ([74.125.82.46]) by smtp.strato.de (RZmta 37.21 AUTH) with ESMTPSA id 9031e9s29C4oKbz (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA (curve secp384r1 with 384 ECDH bits, eq. 7680 bits RSA)) (Client did not present a certificate) for ; Wed, 9 Mar 2016 13:04:50 +0100 (CET) Received: by mail-wm0-f46.google.com with SMTP id l68so189486255wml.0 for ; Wed, 09 Mar 2016 04:04:50 -0800 (PST) X-Gm-Message-State: AD7BkJI1nfOZ0bVyC/rTUtJASGf+dCSQdTUxfzdO42MJWULTmogxdjYoeHvkYEigA25F1m96rJmFBm7h+IHnKg== MIME-Version: 1.0 X-Received: by 10.28.150.19 with SMTP id y19mr17700408wmd.56.1457525090328; Wed, 09 Mar 2016 04:04:50 -0800 (PST) Received: by 10.194.51.36 with HTTP; Wed, 9 Mar 2016 04:04:50 -0800 (PST) In-Reply-To: References: Date: Wed, 9 Mar 2016 13:04:50 +0100 X-Gmail-Original-Message-ID: Message-ID: To: Derick Rethans Cc: Pierrick Charron , PHP Internals , =?UTF-8?B?QnJvbmlzxYJhdyBCaWHFgmVr?= Content-Type: multipart/alternative; boundary=001a114b3d9442eb9d052d9c8132 Subject: Re: [PHP-DEV] [RFC Discussion] Catching multiple exception types From: me@kelunik.com (Niklas Keller) --001a114b3d9442eb9d052d9c8132 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 2016-03-09 12:52 GMT+01:00 Derick Rethans : > Hi! > > On Tue, 8 Mar 2016, Pierrick Charron wrote: > > > 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 > > Would it not be better, to have your Exceptions extend a common base > class in this case? Or perhaps, which I think is even better, to have > your Exception classes implement a common interface that you can catch > against. That I believe should already work. > This assumes they're my exceptions and I can change the code. Doesn't work with libraries having not that good exception structures or even leaking their dependency's exceptions. > What you are asking PHP users to do with a multiple catch like this, is > to test in each catch's statement block to test for each class again. > No, usually it's enough that they're all extending Exception / Throwable. You just can't catch Exception / Throwable, because that would catch all exceptions. If you have a multi-catch, it doesn't matter which exception is thrown and it's never checked, otherwise you'd use two blocks directly. Regards, Niklas > Neither the inheritence or implements options from the previous > paragraph have that issue. > > cheers, > Derick > --001a114b3d9442eb9d052d9c8132--