collectException and nothrow

Daniel Murphy via Digitalmars-d digitalmars-d at puremagic.com
Sat Nov 8 21:42:00 PST 2014


"Casey"  wrote in message news:kymxuhfmugteozqlfgmo at forum.dlang.org...

> Good evening,
>
> I have a question for you.  Why does collectException violate the noThrow 
> attribute?  I would have thought that since it captures an Exception, it 
> would allow the method that normally would throw an exception to be used 
> within a noThrow method.  I did get the same effect by nesting it within a 
> assumeNoThrow method, but I'm still curious as to why collectException 
> doesn't make the same guarantee.
>
> Btw: this is with dmd 2.066.1.

import std.exception;

void main() nothrow
{
    collectException({ throw new Exception(null); });
}

Works fine to me.  Are you catching 'Exception' or catching a specific 
Exception subtype?  If the latter, there's your answer - other types of 
exceptions will still leak through. 



More information about the Digitalmars-d mailing list