From 8beeba81db3a5492aef52b712b47275013c74935 Mon Sep 17 00:00:00 2001 From: saicaca Date: Fri, 20 Sep 2024 01:11:07 +0800 Subject: [PATCH] feat: more readable error message for image not found --- src/components/misc/ImageWrapper.astro | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/components/misc/ImageWrapper.astro b/src/components/misc/ImageWrapper.astro index 18cac2c..610554f 100644 --- a/src/components/misc/ImageWrapper.astro +++ b/src/components/misc/ImageWrapper.astro @@ -32,10 +32,11 @@ if (isLocal) { let normalizedPath = path .normalize(path.join('../../', basePath, src)) .replace(/\\/g, '/') - img = await files[normalizedPath]() - if (!img) { - console.error(`No image found for path ${normalizedPath}`) + const file = files[normalizedPath] + if (!file) { + console.error(`\n[ERROR] Image file not found: ${normalizedPath.replace('../../', 'src/')}`) } + img = await file() } const imageClass = 'w-full h-full object-cover'