Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:91671 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 94910 invoked from network); 15 Mar 2016 16:23:58 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 15 Mar 2016 16:23:58 -0000 Authentication-Results: pb1.pair.com header.from=patrickallaert@php.net; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=patrick.allaert@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.213.43 as permitted sender) X-PHP-List-Original-Sender: patrick.allaert@gmail.com X-Host-Fingerprint: 209.85.213.43 mail-vk0-f43.google.com Received: from [209.85.213.43] ([209.85.213.43:35332] helo=mail-vk0-f43.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 53/03-10575-D1738E65 for ; Tue, 15 Mar 2016 11:23:58 -0500 Received: by mail-vk0-f43.google.com with SMTP id e6so27299282vkh.2 for ; Tue, 15 Mar 2016 09:23:57 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=YRhRz3aAjY8JBaS+5YRjbLjm1BZv8GHMY207J5CZYro=; b=Cv9dydAgKgZkFY+PXI9eF+bBwBsOQKYCCtq19GcCqfljQvw995ipIFf2pYzP/Y+6Ly wPq8/p8JvT/PwY6Eu2c5LAUW+4PTRU/cWi5tGmvxfoSAYTSaOsV6BTynhNZeZAIUeZNM Uvs8RbimoQzWGQlJ18rN5566tmqx0Y3o+p6aMCBSQx/IzX/0Gp4g9CF2bi/KPqXxpBhl M5woXvu0NT5mMLsB0vek3RZylXWJ78UhLsjYe0mG2m4+1E1tA45H9+FnABUUsyNXQO6p ebTTrg6CuCo9L0cU0y7+N7ZCxJxtF/CKT2fNY+N5Yzjf1vjjK4iK3htGkYlFnNOHZftl uEsg== X-Gm-Message-State: AD7BkJI8bt5l6AarlJz19brsyxFi2OhasBcSgb6THufFqTHvh/4LckTiH+1mu44n0gijJWBzXFIoZwpBfIs5Rw== X-Received: by 10.31.159.1 with SMTP id i1mr25736155vke.99.1458059035056; Tue, 15 Mar 2016 09:23:55 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Tue, 15 Mar 2016 16:23:45 +0000 Message-ID: To: Marco Pivetta , Pierrick Charron Cc: Derick Rethans , PHP internals , =?UTF-8?B?QnJvbmlzxYJhdyBCaWHFgmVr?= Content-Type: multipart/alternative; boundary=001a11415a78d8a143052e18d263 Subject: Re: [PHP-DEV] [RFC Discussion] Catching multiple exception types From: patrickallaert@php.net (Patrick ALLAERT) --001a11415a78d8a143052e18d263 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Hi, Le mer. 9 mars 2016 =C3=A0 14:08, Marco Pivetta a =C3= =A9crit : > On 9 March 2016 at 14:03, Pierrick Charron wrote: > > > Hi Derick > > > > I agree that most of the time the best solution is to implement a clean > > exception hierarchy but as stated in the RFC : > > > > "A solution to fix this problem on the user level would be to implement= a > > common interface for ExceptionType1 and ExceptionType2 and catch it. > > However, this is only possible when you control the exception hierarchy > in > > your own code, but not possible when you don't control the code." > > > > I understand the use-case, but I don't see it as a widespread scenario. I= n > most cases, I've been doing something like following: > > public function stuff() > { > try { > $this->willFail(); > } catch (FirstException $e) { > $this->handleFailure($e); > } catch (SecondException $e) { > $this->handleFailure($e); > } catch (ThirdException $e) { > $this->handleFailure($e); > } > } > > Even then, this is a rare eventuality, and as pointed out above, usually > fixed when wrapping exceptions correctly, if you have control over the > exception types). > Seems way below the 80/20 use-case to me, and introduces syntax changes a= s > well. +1 I will add to this that Exceptions must remain... exceptional! Too much projects relies already on tens or hundreds of business exception while those are mostly common "error" conditions that are better handled with dedicated API calls. To me, it doesn't look like a reasonable change when we consider the number of tools/IDE to adapt compared to the possible usage of it. Cheers, Patrick --001a11415a78d8a143052e18d263--