scope(failure): get exception

Jonathan M Davis jmdavisProg at gmx.com
Fri Oct 26 14:33:48 PDT 2012


On Friday, October 26, 2012 19:53:04 Justin Whear wrote:
> Is there a way to get the current exception inside a scope(failure)? I
> have a try..catch around my main loop which simply logs the caught
> exception and rethrows it. I'd like to replace this with a simple scope
> (failure) but I haven't found any way to access the exception causing the
> unwinding.

If you want to see the exception, you must catch it. scope statements do not 
provide access to exceptions. So, scope works great as long as you don't need 
access to the exception, but if you do, you need to use try-catch blocks.

- Jonathan M Davis


More information about the Digitalmars-d-learn mailing list