DenoDDeno
Powered by
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?
Deno banner
DenoJoin
Chat about Deno, a modern runtime for JavaScript and TypeScript.
20,944Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Next throwing an error that seems to be "Deno not defined"
AirmanEpicAAirmanEpic / help
17mo ago
Why isn't this error caught?
Captain π—•π—˜π—˜π—™πŸ₯©CCaptain π—•π—˜π—˜π—™πŸ₯© / help
3y ago
`@sentry/node` is throwing an export error on Deno Deploy
Nissan AhmedNNissan Ahmed / help
3y ago
Pass JS function to an Op that can be called after the Op ends
ExidexEExidex / help
17mo ago