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."

On 9 March 2016 at 06:52, Derick Rethans <der...@php.net> wrote:

> 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

Reply via email to