Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:91585 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 66274 invoked from network); 9 Mar 2016 13:08:36 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 9 Mar 2016 13:08:36 -0000 Authentication-Results: pb1.pair.com smtp.mail=ocramius@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=ocramius@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.217.178 as permitted sender) X-PHP-List-Original-Sender: ocramius@gmail.com X-Host-Fingerprint: 209.85.217.178 mail-lb0-f178.google.com Received: from [209.85.217.178] ([209.85.217.178:34834] helo=mail-lb0-f178.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 2C/22-53667-25020E65 for ; Wed, 09 Mar 2016 08:08:35 -0500 Received: by mail-lb0-f178.google.com with SMTP id bc4so64366042lbc.2 for ; Wed, 09 Mar 2016 05:08:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=7AJnycdN6kBOr5bYq6ne41aEufVwg46dp42h8dMIwo8=; b=tiPs3oUf42opRy+3o1OfU32X1YJzW63FEkT9NlFb+xoldpXYACXwlpBPm7W+/I0gEs Y8cU2OE+E+SY95+ojq8+rUWRC03IM4kRgchipw/kiblQjKXBV7PVRPXMlqQU9aL9ynkN mnUp0nfgGyPHUMip0f3eIgyTAKb0ixQhlAqHcYFExGCx25dSKzhs51WeDYpTfXDxu6Vw hdzT0FfSvcwYk6FJkkN7DoUgNWEKNSYi+xGzt0Lw6X+goNyywxXWiQAU33NNdd0dFj++ Ul4Yvi/LFlbvsKMWDnZTIX5XB/3Ygz2WRaszZo4QXn8G5RmIPhcHwVzkvPTkPYcCXp12 XKvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=7AJnycdN6kBOr5bYq6ne41aEufVwg46dp42h8dMIwo8=; b=NPje638BKZllnthUp8dM4/o5cgRRP+a/pYEuUhrBErF1dBega1XICpmTqhbkmbYLk0 G4oCyxo+XmTzIyuGUg/HsGSxNyPWherviNxR5gGrbqgJsYb3DTz9knUfKdePBQDbm8lw jHsFzj+34vDQZhc0UzNBaQfwBNm1VBEazmSlM1KI1c6pleIbCmr3AB98TeM4PDwZJ2Uu W89DhCWlYrIGbo7TeUI6TRh/0OCApd485A1MvDFt6iPbBT5ls2H4Mw7JjyyeRBmvmD46 Y0FKB156ifSel+1Iu4CxCJwrOHtNgoaUFOmIA/M7zlYMHDjDA/vBZunzfDlEWmVNp3qx WACg== X-Gm-Message-State: AD7BkJIpPrNvW4LCItmf6xfecgtTcZMu1QYoWzBjEEk7XaeEe9Rk/5jdYvj3YMm61tm/tYem2LuhJVMcVnrUMQ== X-Received: by 10.112.188.134 with SMTP id ga6mr6891091lbc.77.1457528911466; Wed, 09 Mar 2016 05:08:31 -0800 (PST) MIME-Version: 1.0 Received: by 10.112.59.167 with HTTP; Wed, 9 Mar 2016 05:08:11 -0800 (PST) In-Reply-To: References: Date: Wed, 9 Mar 2016 14:08:11 +0100 Message-ID: To: Pierrick Charron Cc: Derick Rethans , PHP internals , =?UTF-8?B?QnJvbmlzxYJhdyBCaWHFgmVr?= Content-Type: multipart/alternative; boundary=001a11c37ad204989f052d9d657e Subject: Re: [PHP-DEV] [RFC Discussion] Catching multiple exception types From: ocramius@gmail.com (Marco Pivetta) --001a11c37ad204989f052d9d657e Content-Type: text/plain; charset=UTF-8 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. In 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 as well. Cheers, Marco Pivetta http://twitter.com/Ocramius http://ocramius.github.com/ --001a11c37ad204989f052d9d657e--