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

View File

@ -108,8 +108,10 @@ function DiceInteraction({
}
});
} catch (error) {
if (error instanceof Error) {
setError(error);
}
}
}, [onSceneMount]);
const selectedMeshRef = useRef<AbstractMesh | null>(null);

View File

@ -562,8 +562,10 @@ export async function getGridSizeFromImage(image: HTMLImageElement) {
try {
prediction = await gridSizeML(image, candidates);
} catch (error) {
if (error instanceof Error) {
logError(error);
}
}
if (!prediction) {
prediction = gridSizeHeuristic(image, candidates);

View File

@ -67,6 +67,7 @@ function useImageDrop(
}
}
} catch (e) {
if (e instanceof Error) {
if (e.message === "Failed to fetch") {
addToast("Unable to import image: failed to fetch");
} else {
@ -74,6 +75,7 @@ function useImageDrop(
}
}
}
}
const files = event.dataTransfer?.files || [];
for (let file of files) {