DEV Community

Discussion on: NodeJS Create folder if not exists in 3 lines - No dependencies

Collapse
 
puruvj profile image
PuruVJ

Thank you for the advice. I didn't think of that. Would fire right back in cloud environments 😅

Is there any reference of errors that I can look up for the error codes?

Collapse
 
hendrikfoo profile image
Hendrik Richert

Thats a good question :-) I couldn't find a list of possible exceptions for promises.mkdir
My proposed solution would be to not catch any exceptions, but instead do a check if the dir exists first, and only if it doesn't try to create it. In that case you would be safe to report any errors back to the user.

But then again that would ruin your 3 lines example ;-)

Thread Thread
 
puruvj profile image
PuruVJ

But then again that would ruin your 3 lines example ;-)

Exactly! Not so catchy anymore