Re: [PHP-DEV] Re: Throwable::addSuppressed()

2015-08-02 Thread Stephen Coakley
On 08/02/2015 03:50 AM, Markus Malkusch wrote: Stephen Coakley: So what should be the desired behavior, in regard to bug #68270? One possible behavior would be to, if an exception is thrown inside a finally block, to attach the uncaught exception from the try block via the addSupressed() method

Re: [PHP-DEV] Re: Throwable::addSuppressed()

2015-08-02 Thread Markus Malkusch
Stephen Coakley: > This is the behavior in both Java and C#. Python has a different > approach. Python has two properties that contain previous exceptions: > __context__, which holds implicitly chained exceptions, and __cause__, > which holds explicitly chained exceptions. This system makes a ton

Re: [PHP-DEV] Re: Throwable::addSuppressed()

2015-08-02 Thread Markus Malkusch
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 th

Re: [PHP-DEV] Re: Throwable::addSuppressed()

2015-08-02 Thread Markus Malkusch
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

Re: [PHP-DEV] Re: Throwable::addSuppressed()

2015-08-02 Thread Markus Malkusch
Stephen Coakley: > So what should be the desired behavior, in regard to bug #68270? One > possible behavior would be to, if an exception is thrown inside a > finally block, to attach the uncaught exception from the try block via > the addSupressed() method. The last exception is thrown, and the >

Re: [PHP-DEV] Re: Throwable::addSuppressed()

2015-08-01 Thread Stephen Coakley
On 08/01/2015 09:44 AM, Markus Malkusch wrote: Christoph Becker: Markus Malkusch wrote: I'd like to revise that. I'd just learned that finally does indeed fit here, as it would automatically glue exceptions: [..] Note that there's an open bug report () regarding

Re: [PHP-DEV] Re: Throwable::addSuppressed()

2015-08-01 Thread Stephen Coakley
On 08/01/2015 09:44 AM, Markus Malkusch wrote: Christoph Becker: Markus Malkusch wrote: I'd like to revise that. I'd just learned that finally does indeed fit here, as it would automatically glue exceptions: [..] Note that there's an open bug report () regarding

Re: [PHP-DEV] Re: Throwable::addSuppressed()

2015-08-01 Thread Markus Malkusch
Christoph Becker: > Markus Malkusch wrote: >> >> I'd like to revise that. I'd just learned that finally does indeed fit >> here, as it would automatically glue exceptions: [..] > Note that there's an open bug report () > regarding this issue. Thank you for pointing to

Re: [PHP-DEV] Re: Throwable::addSuppressed()

2015-08-01 Thread Christoph Becker
Markus Malkusch wrote: > Markus Malkusch: > >> 2) You are loosing one stack trace > > I'd like to revise that. I'd just learned that finally does indeed fit > here, as it would automatically glue exceptions: > > try { > throw new Exception("A"); > > } finally { > throw new Exception("B

Re: [PHP-DEV] Re: Throwable::addSuppressed()

2015-08-01 Thread Markus Malkusch
Markus Malkusch: > 2) You are loosing one stack trace I'd like to revise that. I'd just learned that finally does indeed fit here, as it would automatically glue exceptions: try { throw new Exception("A"); } finally { throw new Exception("B"); } This prints both exceptions: PHP Fa

[PHP-DEV] Re: Throwable::addSuppressed()

2015-07-31 Thread Stephen Coakley
On 07/31/2015 08:25 PM, Markus Malkusch wrote: Stephen Coakley: Interesting thought, but how is this different than including a previous throwable and throwing a new, more descriptive exception? } catch (Exception $e1) { try { $resource->close(); } catch (ResourceExceptio

[PHP-DEV] Re: Throwable::addSuppressed()

2015-07-31 Thread Markus Malkusch
Stephen Coakley: > Interesting thought, but how is this different than including a previous > throwable and throwing a new, more descriptive exception? > > } catch (Exception $e1) { > try { > $resource->close(); > } catch (ResourceException $e2) { > // Pass in $e2 as t

[PHP-DEV] Re: Throwable::addSuppressed()

2015-07-31 Thread Markus Malkusch
Stephen Coakley: > Interesting thought, but how is this different than including a previous > throwable and throwing a new, more descriptive exception? Thank you for asking. If you would have again a look at the code fragment from the previous mail you will notice that there are two immutable exce

[PHP-DEV] Re: Throwable::addSuppressed()

2015-07-31 Thread Stephen Coakley
On 07/28/2015 04:51 PM, Markus Malkusch wrote: Hi PHP So I read that there's this Throwable interface coming. Great! How about extending it with one further method: void Throwable::addSuppressed(Throwable exception) Semantic is the same as Java's Throwable.addSuppressed()ยน. Why? Well consider