On 9 March 2016 at 14:03, Pierrick Charron <[email protected]> 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/