INNER CODE UNIT · TypeScript

isExpectedFileSystemError

cloudflare/workers-sdk · packages/autoconfig/src/details/index.ts:44

function isExpectedFileSystemError(error: unknown): boolean {
	return (
		typeof error === "object" &&
		error !== null &&
		"code" in error &&
		(error.code === "ENOENT" ||
			error.code === "ENOTDIR" ||
			error.code === "EACCES" ||
			error.code === "EPERM")
	);
}

async function getPathStats(path: string): Promise<Stats | undefined> {
	try {
		return await stat(path);
	} catch (error) {
		if (isExpectedFileSystemError(error)) {
			return undefined;

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…