Re: Re: Throwable::addSuppressed()

From: Date: Sun, 02 Aug 2015 09:12:14 +0000
Subject: Re: Re: Throwable::addSuppressed()
References: 1 2 3 4 5 6 7 8  Groups: php.internals 
Request: Send a blank email to internals+get-87497@lists.php.net to get a copy of this message
Markus Malkusch: > The try-finally scenario involves only one supressed > exception. I'd like to see a possibility to add more supressed > exceptions Actually try-finally can already involve several supressed exceptions as well: try { throw new Exception("Exception 1"); } finally { try { throw new Exception("Exception 2"); } finally { throw new Exception("Exception 3"); } } So in this scenario I exception 3 will be the resulting exception and as already defined within your mail exception 2 should be its supressed exception. But what about exception 1? This could now be the supressed exception of exception 2 or added to the list of supressed exceptions of exception 3. I'd argue *adding* it to the resulting exception of the finally block makes the most sense. This would be exception 3 in this case and therefore needs to be a list. Why does this make more sense. I'd argue it's more expected and intuitive, as exception 2 is optional. Just consider a similar case without exception 2: try { throw new Exception("Exception 1"); } finally { try { } finally { throw new Exception("Exception 3"); } } In this case the only place for the suppressed exception 1 can be exception 3. For consistency and simplicity I'd therefore suggest that a Throwable has a list of supressed exceptions and a suppressed exception is always added to the resulting exception of a finally block. Markus Malkusch

« previous php.internals (#87497) next »