mirror of
https://github.com/denoland/deno.git
synced 2025-08-03 02:22:40 +00:00
feat(runtime): improve error messages of runtime fs (#11984)
This commit annotates errors returned from FS Deno APIs to include paths that were passed to the API calls. Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
This commit is contained in:
parent
423b02d889
commit
668b400ff2
17 changed files with 589 additions and 135 deletions
|
@ -40,15 +40,23 @@ unitTest({ permissions: { read: false } }, function readDirSyncPerm() {
|
|||
});
|
||||
|
||||
unitTest({ permissions: { read: true } }, function readDirSyncNotDir() {
|
||||
assertThrows(() => {
|
||||
Deno.readDirSync("cli/tests/testdata/fixture.json");
|
||||
}, Error);
|
||||
assertThrows(
|
||||
() => {
|
||||
Deno.readDirSync("cli/tests/testdata/fixture.json");
|
||||
},
|
||||
Error,
|
||||
`readdir 'cli/tests/testdata/fixture.json'`,
|
||||
);
|
||||
});
|
||||
|
||||
unitTest({ permissions: { read: true } }, function readDirSyncNotFound() {
|
||||
assertThrows(() => {
|
||||
Deno.readDirSync("bad_dir_name");
|
||||
}, Deno.errors.NotFound);
|
||||
assertThrows(
|
||||
() => {
|
||||
Deno.readDirSync("bad_dir_name");
|
||||
},
|
||||
Deno.errors.NotFound,
|
||||
`readdir 'bad_dir_name'`,
|
||||
);
|
||||
});
|
||||
|
||||
unitTest({ permissions: { read: true } }, async function readDirSuccess() {
|
||||
|
@ -94,3 +102,13 @@ unitTest(
|
|||
}
|
||||
},
|
||||
);
|
||||
|
||||
unitTest({ permissions: { read: true } }, async function readDirNotFound() {
|
||||
await assertRejects(
|
||||
async () => {
|
||||
await Deno.readDir("bad_dir_name")[Symbol.asyncIterator]().next();
|
||||
},
|
||||
Deno.errors.NotFound,
|
||||
`readdir 'bad_dir_name'`,
|
||||
);
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue