-
Notifications
You must be signed in to change notification settings - Fork 632
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(fs/walk): WalkError class #3054
Conversation
Co-authored-by: Yoshiya Hinosawa <stibium121@gmail.com>
@lino-levan Can you also add a simple test case which checks WalkError being thrown? |
SGTM, I'll get around to it when I get around to it. Maybe tomorrow if I get the chance. |
@kt3k I tried my hand at writing a test for this but can't think of a way for this to error out consistently (without relying on something like removing a folder after we already started walking it). Do you have any ideas? |
Co-authored-by: Jesse Jackson <jsejcksn@users.noreply.github.com>
@lino-levan I just tested this locally and it reliably throws every run:
// deno test --allow-read=exampleRootTestDir --allow-write=exampleRootTestDir
import { assertRejects } from "https://deno.land/std@0.178.0/testing/asserts.ts";
import { walk } from "https://deno.land/std@0.178.0/fs/walk.ts";
Deno.test("throws", async () => {
const dir = "exampleRootTestDir";
await assertRejects(async () => {
await Deno.mkdir(dir);
for await (const _walkEntry of walk(dir)) await Deno.remove(dir);
});
});
Check out the |
LGTM, thanks for your help on this PR! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks! @lino-levan
closes #3023.
The concept is that if you want to catch an error and see what caused it, you should be able to use
err.cause instanceof ErrorClassYouWantToCatch
.