StokestackS
Denoβ€’2y agoβ€’
13 replies
Stokestack

mkdirsync is throwing an exception that can't be caught?

This code used to work, so I don't know what changed.

export default
{
validateEnvironment()
{
try
{
Deno.mkdirSync(config.UPLOAD_PATH); // <- THROWS
}
catch (error)
{
if(error.name == "AlreadyExists")
{
console.log("Uploads directory exists.");
}
else
{
console.error(error);
return;
}
}

console.log("Environment validated.");
}
}

I call this on startup in my main.ts. It's all synchronous. But the server halts with an exception because the directory already exists. Why?
Was this page helpful?