feat(image): inline upload-error feedback parity with FontManager#43
Conversation
There was a problem hiding this comment.
Code Review
This pull request implements error handling for image uploads in the image registry component, adding an 'uploadError' translation key across all supported locales. The image component now tracks an 'uploadFailed' state and displays an inline error message if image loading or conversion fails. Feedback was provided to explicitly log caught errors to the console to assist with debugging, as the current implementation suppresses them despite the code comments suggesting they would be visible.
| } catch { | ||
| // loadImageFile rejects on non-image MIME, oversized files, decode | ||
| // failures; imageToGFA can also throw. Surface a single inline hint | ||
| // (mirrors FontManager) — the underlying error is already in the | ||
| // console for debugging. | ||
| setUploadFailed(true); |
There was a problem hiding this comment.
The comment mentions that the error is already in the console, but catching it without re-throwing or logging it actually prevents it from appearing there (as it is no longer an unhandled rejection). It is best to explicitly log the error to aid in debugging issues like invalid image formats or conversion failures.
} catch (err) {
// loadImageFile rejects on non-image MIME, oversized files, decode
// failures; imageToGFA can also throw. Surface a single inline hint
// (mirrors FontManager) — we log the error to the console for debugging.
console.error(err);
setUploadFailed(true);
}
The image upload handler had `try/finally` without `catch`, so failures (non-image MIME, oversize, decode error, GFA exception) propagated as unhandled rejections with no user signal. Add `uploadFailed` state and a small inline hint matching FontManager's pattern. Catch swallows the underlying error intentionally — codebase has no production logging convention; specific causes are debugged with a devtools breakpoint.
637ff81 to
9178895
Compare
The image upload handler had
try/finallywithoutcatch, so failures (non-image MIME, oversize, decode error, GFA exception) propagated as unhandled rejections with no user signal. AdduploadFailedstate and a small inline hint matching FontManager's pattern.