fix: unify error message to "Failed to fetch" and exit on load failure
Browse filesShow a clean "Failed to fetch" message in the UI and call exit() so the
test terminates immediately instead of hanging on unsupported images.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
src/ink-picture/__tests__/LocalPicture.test.tsx
CHANGED
|
@@ -68,8 +68,9 @@ function App() {
|
|
| 68 |
pixelHeight: finalH_pixels,
|
| 69 |
});
|
| 70 |
} catch (e) {
|
| 71 |
-
console.error(
|
| 72 |
setErr(true);
|
|
|
|
| 73 |
}
|
| 74 |
})();
|
| 75 |
}, []);
|
|
@@ -81,7 +82,7 @@ function App() {
|
|
| 81 |
}, [exit]);
|
| 82 |
|
| 83 |
if (err) {
|
| 84 |
-
return <Text color="red">Failed to
|
| 85 |
}
|
| 86 |
|
| 87 |
if (!dimensions) {
|
|
|
|
| 68 |
pixelHeight: finalH_pixels,
|
| 69 |
});
|
| 70 |
} catch (e) {
|
| 71 |
+
console.error(e);
|
| 72 |
setErr(true);
|
| 73 |
+
exit();
|
| 74 |
}
|
| 75 |
})();
|
| 76 |
}, []);
|
|
|
|
| 82 |
}, [exit]);
|
| 83 |
|
| 84 |
if (err) {
|
| 85 |
+
return <Text color="red">Failed to fetch: {IMAGE_PATH}</Text>;
|
| 86 |
}
|
| 87 |
|
| 88 |
if (!dimensions) {
|
src/ink-picture/utils/jimpURL.ts
CHANGED
|
@@ -24,9 +24,7 @@ export async function loadImageFromUrl(url: string) {
|
|
| 24 |
const mime = contentType.split(";")[0].trim().toLowerCase();
|
| 25 |
|
| 26 |
if (mime && !SUPPORTED_MIME_TYPES.has(mime)) {
|
| 27 |
-
throw new Error(
|
| 28 |
-
`Unsupported image format: ${mime}. Supported: ${[...SUPPORTED_MIME_TYPES].join(", ")}`,
|
| 29 |
-
);
|
| 30 |
}
|
| 31 |
|
| 32 |
const arrayBuffer = await response.arrayBuffer();
|
|
|
|
| 24 |
const mime = contentType.split(";")[0].trim().toLowerCase();
|
| 25 |
|
| 26 |
if (mime && !SUPPORTED_MIME_TYPES.has(mime)) {
|
| 27 |
+
throw new Error("Failed to fetch");
|
|
|
|
|
|
|
| 28 |
}
|
| 29 |
|
| 30 |
const arrayBuffer = await response.arrayBuffer();
|