don't throw error

This commit is contained in:
Abhinav 2023-02-07 16:02:10 +05:30
parent 3287ae587e
commit 4c695f83c6

View file

@ -188,16 +188,17 @@ export async function isFolder(dirPath: string) {
const stats = await fs.stat(dirPath); const stats = await fs.stat(dirPath);
return stats.isDirectory(); return stats.isDirectory();
} catch (e) { } catch (e) {
let err = e;
// if code is defined, it's an error from fs.stat // if code is defined, it's an error from fs.stat
if (typeof e.code !== 'undefined') { if (typeof e.code !== 'undefined') {
// ENOENT means the file does not exist // ENOENT means the file does not exist
if (e.code === 'ENOENT') { if (e.code === 'ENOENT') {
return false; return false;
} }
throw Error(`fs error code: ${e.code}`); err = Error(`fs error code: ${e.code}`);
} else {
throw e;
} }
logError(err, 'isFolder failed');
return false;
} }
} }