Markus Malkusch:

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

Actually I my self was not really certain why adding it to the resulting
exception is better than setting it to the first exception. So I'd like
to present a further scenario which hopefully helps to decide for the
better definition:

try {
    throw new Exception("Exception 1");

} finally {
    try {
        throw new Exception("Exception 2");

    } catch (Exception $e) {
         // Don't throw anything cause this is expected.

    } finally {
        throw new Exception("Exception 3");
    }
}

So in this scenario again exception 3 will be the resulting exception.
exception 2 is expected and caught. Regarding exception 1 consider these
two definitions:

1) The supressed exception will be attached to the first raised
exception. This would be exception 2 in this case. Exception 2 is
handled and the information about exception 1 is lost.

2) The supressed exception is added to the resulting exception of the
finally block. This would be exception 3 in this case. The information
is still present.

So therefore I would vote for definition two. But I am also curious on
other opinions.

Markus Malkusch

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to