iterate over a directory, dealing with permission errors

xray xray at isd.lu
Sun May 23 14:33:10 UTC 2021


On Sunday, 23 May 2021 at 14:03:19 UTC, Mike Parker wrote:
> On Sunday, 23 May 2021 at 13:29:26 UTC, xray wrote:
>> On Friday, 18 September 2015 at 13:53:45 UTC, Meta wrote:
>>> I think you could use std.exception.ifThrown in this case.
>
>> Hello, is it something that still works today ?
>> because I have an error :
>>
>> "no property `ifThrown` for type `std.file.DirIterator"
>>
>> same if I use handle! directly. Do I need to import some 
>> modules ?
>
> `std.exception.ifThrown` means `ifThrown` is in the 
> `std.exception` module, so that's what you need to import.
>
> https://dlang.org/phobos/std_exception.html#ifThrown

Thanks Mike. Now I have a
"The error handler's return value(DirEntry) does not have a 
common type with the expression(DirIterator)."

So I removed the ifThrown for while and it compiles....but still 
doesn't work because of an access denied file (FileException).

I thought the exception will be caught be the closure.



More information about the Digitalmars-d mailing list