refactor: ♻️ improve readDriectory function

I improved use of errorMessage
This commit is contained in:
Axel Olausson Holtenäs 2023-10-01 17:18:00 +02:00
parent 83c0af64c9
commit 61af819a54

View file

@ -14,11 +14,8 @@ export default async (filePath: string) => {
}); });
return result; return result;
} catch (error) { } catch (error) {
logger.error({ const errorMessage = `Error checking directory ${filePath}: ${error}`;
message: `Error checking directory ${filePath}`, logger.error({ message: errorMessage, error, directoryPath });
error, throw new Error(errorMessage);
directoryPath,
});
throw new Error(`Error checking directory ${filePath}: ${error}`);
} }
}; };