Hi,

Le mer. 9 mars 2016 à 14:08, Marco Pivetta <ocram...@gmail.com> a écrit :

> On 9 March 2016 at 14:03, Pierrick Charron <pierr...@adoy.net> 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.


+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

Reply via email to