On Thursday, 13 July 2017 at 10:56:20 UTC, unDEFER wrote:
Seems I have found. I must do:
try{
    File file;
    try {
        file = File(path);
    }
    catch (Exception exp)
    {
        return;
    }

    //Some actions with file
}
catch (ErrnoException)
{
    return;
}

Well, yes, you can also encompass your entire function body in a try catch, though that makes your code somewhat hard to read[1]. With these many try/catches you may want to take a look at std.exception.collectException[2].

[1] https://en.wikipedia.org/wiki/Spaghetti_code
[2] https://dlang.org/phobos/std_exception.html#.collectException

Reply via email to