From 61af819a544cc7ba8b87fec55d746ef144f3c8e4 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Sun, 1 Oct 2023 17:18:00 +0200 Subject: [PATCH] refactor: :recycle: improve readDriectory function I improved use of errorMessage --- src/utils/readDirectory.ts | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/utils/readDirectory.ts b/src/utils/readDirectory.ts index be258ab..24e7bae 100644 --- a/src/utils/readDirectory.ts +++ b/src/utils/readDirectory.ts @@ -14,11 +14,8 @@ export default async (filePath: string) => { }); return result; } catch (error) { - logger.error({ - message: `Error checking directory ${filePath}`, - error, - directoryPath, - }); - throw new Error(`Error checking directory ${filePath}: ${error}`); + const errorMessage = `Error checking directory ${filePath}: ${error}`; + logger.error({ message: errorMessage, error, directoryPath }); + throw new Error(errorMessage); } };