scope exception do not rise

Suliman via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Nov 5 06:01:21 PST 2014


I can't understand what I am missing. Try-catch block also do not 
handle exception:

void main()
{
	string fname = "app.d1"; //file name with error
	string current_folder = (getcwd() ~"\\");
	writeln(current_folder);
	openFile(fname, current_folder);
}

void openFile(string fname, string current_folder)
{
		try
		{
			auto file = readText(current_folder ~ fname);
			if(exists(current_folder ~ fname))
			scope(success)
				writeln("success");
		}

		catch(Exception e)
		{
			writeln(e); //what class of error I am handling? any?
		}

	
}


More information about the Digitalmars-d-learn mailing list