Skip to content

Commit

Permalink
Refactor image and icon loading error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
JeremyDolle committed Oct 9, 2024
1 parent 26d7146 commit 1e110b8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@ function AssetByVariant({ path, extension = 'png', ...props }: Props) {
setImage(fetchedModule);
} catch (error) {
// eslint-disable-next-line no-console
console.error(`Couldn't load the image: ${path}.${extension} for the variant ${variant}, Fallback to default`, error);
console.error(
`Couldn't load the image: ${path}.${extension} for the variant ${variant}, Fallback to default`,
error,
);
setImage(defaultSource);
}
} catch (error) {
Expand Down
6 changes: 4 additions & 2 deletions template/src/components/atoms/IconByVariant/IconByVariant.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,12 @@ function IconByVariant({ path, ...props }: Props) {
setIcon(fetchedModule.default);
} catch (error) {
// eslint-disable-next-line no-console
console.error(`Couldn't load the icon: ${path}.${EXTENSION} for the variant ${variant}, Fallback to default`, error);
console.error(
`Couldn't load the icon: ${path}.${EXTENSION} for the variant ${variant}, Fallback to default`,
error,
);
setIcon(defaultSource.default);
}

} catch (error) {
// eslint-disable-next-line no-console
console.error(`Couldn't load the icon: ${path}.${EXTENSION}`, error);
Expand Down

0 comments on commit 1e110b8

Please sign in to comment.