Bogdan Biv
mkdirsync is throwing an exception that can't be caught?
If validateEnvironment() works in the code as you write it, it means you have defined it before. Otherwise validateEnvironment() {} is actually two unrelated pieces of code. It will be interpreted as:
``javascript
validateEnvironment(); /// call to some non existing function
{
/// some unrelated code
}
14 replies
mkdirsync is throwing an exception that can't be caught?
IMO, I'm not sure exactly what's going on in your code but you seem to have dropped the function keyword from the code (before the body function). I'm not experienced at all, it's just my 0.02$
14 replies
mkdirsync is throwing an exception that can't be caught?
This code does throw (prints AlreadyExists on console):
deno run --allow-write=./new_dir main.ts
#main.ts
try {Deno.mkdirSync("new_dir");} catch (error) {console.log(error.name)}
Of course on the first run it does not print out anything, further reruns do print AlreadyExists
Also works:
function validateEnvironment() { try {Deno.mkdirSync("new_dir");} catch (error) {console.log(error.name)}; }
// validateEnvironment();
14 replies