scope block do not handle failure, but try-catch does
Michael via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Thu Dec 11 13:06:41 PST 2014
On Thursday, 11 December 2014 at 20:40:40 UTC, Suliman wrote:
> string dbname = config.getKey("dbname1");
> scope(failure) writeln("look like dbname is missing");
>
> I am using dini and trying to throw exception if value can't be
> extract from config. If I am wrap it's in try-сефср block it's
> work or. But in this situation scope block do not execute and I
> see only stack tracing error on console.
>
> Why? What's wrong. By idea if block failure scope should execute
I'm not 100% sure on this, but I suspect you have to declare the
scope(failure) before you call the code that might execute it.
e.g.
scope(failure) writeln("Looks like the dbname is missing");
string dbname = config.getKey("dbname1");
More information about the Digitalmars-d-learn
mailing list