Re: [RFC Discussion] Catching multiple exception types
| From: | Derick Rethans | Date: | Wed, 09 Mar 2016 11:52:06 +0000 |
| Subject: | Re: [RFC Discussion] Catching multiple exception types | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-91582@lists.php.net to get a copy of this message | ||
Hi!
On Tue, 8 Mar 2016, Pierrick Charron wrote:
> Bronisław Białek 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.
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.
Neither the inheritence or implements options from the previous
paragraph have that issue.
cheers,
Derick