On Friday, 18 September 2015 at 12:27:37 UTC, Robert burner
Schadek wrote:
On Friday, 18 September 2015 at 12:17:25 UTC, John Colvin wrote:
That's neat, didn't know about std.exception.handle
It is at least a year old. I created it because I had a range
that threw, and there was nothing to keep a range going or
reenter it.
Unfortunately, I think there are two problems with your
solution:
1) DirIteratorImpl will throw on popFront, not front. I had to
look at source to find out. Is this a failure of documentation
or is it actually an implementation detail?
That one is trivial RangePrimitive.popFront
foreach(file; dirEntries(args[1], SpanMode.depth)
.handle!(Exception, RangePrimitive.popFront, (e, r) =>
DirEntry())) {
writeln(file.name);
}
Yes, but implicit in this being an OK solution for people is that
no-one ever reorganises the internals of DirIteratorImpl. I guess
One could use handle to deal with *all* the range primitives as a
defensive countermeasure.
2) it doesn't cover the case where args[1] itself is
unreadable, because dirEntries will throw when it's created.
well, creating a DirEntry is not a range operation. handle
can't help you there.
Yup :(