Add error guards to catch blocks

This commit is contained in:
nthouliss
2022-04-01 14:56:55 +11:00
parent 3a0a9b231d
commit c1cde5b94f
3 changed files with 12 additions and 6 deletions
+3 -1
View File
@@ -108,7 +108,9 @@ function DiceInteraction({
}
});
} catch (error) {
setError(error);
if (error instanceof Error) {
setError(error);
}
}
}, [onSceneMount]);
+3 -1
View File
@@ -562,7 +562,9 @@ export async function getGridSizeFromImage(image: HTMLImageElement) {
try {
prediction = await gridSizeML(image, candidates);
} catch (error) {
logError(error);
if (error instanceof Error) {
logError(error);
}
}
if (!prediction) {
+6 -4
View File
@@ -67,10 +67,12 @@ function useImageDrop(
}
}
} catch (e) {
if (e.message === "Failed to fetch") {
addToast("Unable to import image: failed to fetch");
} else {
addToast("Unable to import image");
if (e instanceof Error) {
if (e.message === "Failed to fetch") {
addToast("Unable to import image: failed to fetch");
} else {
addToast("Unable to import image");
}
}
}
}