Why I can't catch the exception?
Suliman via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sun Jun 5 11:02:12 PDT 2016
I really can't understand why try-catch block do not handle
exception.
digit 1 is printing, so exception is accrue after it, but why
nothing in catch block?
http://img.ctrlv.in/img/16/06/05/57546861d8e81.png
Here is my code:
void dbSetup()
{
try
{
//getcwd do not return correct path if run from task
shoulder
string dbpath =
buildPath((thisExePath[0..((thisExePath.lastIndexOf("\\"))+1)]),
dbname);
if(!dbpath.exists)
{
writeln("It's seems you are runnining Application
first time\n You should set up admin password");
auto db = DataBase(dbname);
writeln("1");
auto usersCollection = db.collection!User("Users",
true); // base on struct User
usersCollection.put(User(0, "admin", "123",
"admins")); // defaults
writeln("2");
writeln("[INFO] db with default credentials created");
}
else
{
writeln("[INFO] db exists");
return;
}
}
catch(Exception e)
{
writeln("Can't setup DB");
writeln(e.msg);
}
}
I am using https://gitlab.com/PiotrekDlang/DraftLib/
More information about the Digitalmars-d-learn
mailing list