feat: more readable error message for image not found

This commit is contained in:
saicaca 2024-09-20 01:11:07 +08:00
parent 085fd62a79
commit 8beeba81db
1 changed files with 4 additions and 3 deletions

View File

@ -32,10 +32,11 @@ if (isLocal) {
let normalizedPath = path let normalizedPath = path
.normalize(path.join('../../', basePath, src)) .normalize(path.join('../../', basePath, src))
.replace(/\\/g, '/') .replace(/\\/g, '/')
img = await files[normalizedPath]() const file = files[normalizedPath]
if (!img) { if (!file) {
console.error(`No image found for path ${normalizedPath}`) console.error(`\n[ERROR] Image file not found: ${normalizedPath.replace('../../', 'src/')}`)
} }
img = await file()
} }
const imageClass = 'w-full h-full object-cover' const imageClass = 'w-full h-full object-cover'