On 13.12.2014 23:26, Suliman wrote:
I reread docs and understood that scope not for such case.

Next code is do what I need:
try
{
string dbname = config.getKey("dbname");
string dbpass = config.getKey("dbpass");
string dbhost = config.getKey("dbhost");
string dbport = config.getKey("dbport");
}

catch (Exception msg)
{
writeln("Can't parse config: %s", msg.msg);
}
What you need probably is the following:

string dbpass, dbhost, dbport;

{ // This bracket is intended to define new scope
        // New if in the current scope from now any failure occurs
        // the compiler will call writeln with message
        scope(failure) writeln("Can't parse config: %s", msg.msg);

        dbname = config.getKey("dbname");
        dbpass = config.getKey("dbpass");
        dbhost = config.getKey("dbhost");
        dbport = config.getKey("dbport");
} // the current scope ends, so if a failure happens later writeln won't be called

Reply via email to