summaryrefslogtreecommitdiff
path: root/ext/node
diff options
context:
space:
mode:
authorfamilyboat <84062528+familyboat@users.noreply.github.com>2024-10-27 11:04:35 +0800
committerGitHub <noreply@github.com>2024-10-27 08:34:35 +0530
commitc314b2d8577289078d6b00a0dd58f8f36ff6920a (patch)
tree7ab31f425b81954a896169476f800f5925532ce2 /ext/node
parent05868cc2367d6c827691d7624478157239048bea (diff)
fix(ext/node): add path to `fs.stat` and `fs.statSync` error (#26037)
Diffstat (limited to 'ext/node')
-rw-r--r--ext/node/polyfills/_fs/_fs_stat.ts14
1 files changed, 12 insertions, 2 deletions
diff --git a/ext/node/polyfills/_fs/_fs_stat.ts b/ext/node/polyfills/_fs/_fs_stat.ts
index c4ed82d57..d00c81ffb 100644
--- a/ext/node/polyfills/_fs/_fs_stat.ts
+++ b/ext/node/polyfills/_fs/_fs_stat.ts
@@ -383,7 +383,10 @@ export function stat(
Deno.stat(path).then(
(stat) => callback(null, CFISBIS(stat, options.bigint)),
- (err) => callback(denoErrorToNodeError(err, { syscall: "stat" })),
+ (err) =>
+ callback(
+ denoErrorToNodeError(err, { syscall: "stat", path: getPathname(path) }),
+ ),
);
}
@@ -417,9 +420,16 @@ export function statSync(
return;
}
if (err instanceof Error) {
- throw denoErrorToNodeError(err, { syscall: "stat" });
+ throw denoErrorToNodeError(err, {
+ syscall: "stat",
+ path: getPathname(path),
+ });
} else {
throw err;
}
}
}
+
+function getPathname(path: string | URL) {
+ return typeof path === "string" ? path : path.pathname;
+}