Skip to content

Commit 1e110b8

Browse files
committed
Refactor image and icon loading error handling
1 parent 26d7146 commit 1e110b8

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

template/src/components/atoms/AssetByVariant/AssetByVariant.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,10 @@ function AssetByVariant({ path, extension = 'png', ...props }: Props) {
3636
setImage(fetchedModule);
3737
} catch (error) {
3838
// eslint-disable-next-line no-console
39-
console.error(`Couldn't load the image: ${path}.${extension} for the variant ${variant}, Fallback to default`, error);
39+
console.error(
40+
`Couldn't load the image: ${path}.${extension} for the variant ${variant}, Fallback to default`,
41+
error,
42+
);
4043
setImage(defaultSource);
4144
}
4245
} catch (error) {

template/src/components/atoms/IconByVariant/IconByVariant.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,12 @@ function IconByVariant({ path, ...props }: Props) {
3737
setIcon(fetchedModule.default);
3838
} catch (error) {
3939
// eslint-disable-next-line no-console
40-
console.error(`Couldn't load the icon: ${path}.${EXTENSION} for the variant ${variant}, Fallback to default`, error);
40+
console.error(
41+
`Couldn't load the icon: ${path}.${EXTENSION} for the variant ${variant}, Fallback to default`,
42+
error,
43+
);
4144
setIcon(defaultSource.default);
4245
}
43-
4446
} catch (error) {
4547
// eslint-disable-next-line no-console
4648
console.error(`Couldn't load the icon: ${path}.${EXTENSION}`, error);

0 commit comments

Comments
 (0)