On Wednesday, 5 November 2014 at 12:56:41 UTC, Suliman wrote:
void openFile(string fname, string current_folder)
{
auto file = readText(current_folder ~ fname);
scope(failure)
{
writeln("failure");
}
// writeln(file);
}
if file name do not exists, I want to rise scope exception. But
it's do not rise, and I am getting only standard error like:
std.file.FileException@std\file.d(191):
D:\code\d\App1\source\app.d1: ╨Э╨╡ ╤Г╨┤╨
░╨╡╤В╤Б╤П ╨╜╨░╨╣╤В╨╕ ╤Г╨║╨░╨╖╨░╨╜╨╜╤Л╨╣ ╤Д╨░╨╣╨╗.
----------------
what's wrong? if I use block "success" it's work fine.
Try:
--------
scope(failure){writeln("failure");}
auto file = readText(current_folder ~ fname);
--------
The scope(failure) is translated to a try catch after the
satement you wann monitor.
So put it before