From 97699a95eaf597e461c6eef792ac451310eef945 Mon Sep 17 00:00:00 2001 From: Shawn Date: Thu, 21 May 2026 14:47:34 -0400 Subject: [PATCH] gallery upload: better OCR error messages MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Catches 'unknown error' from Tesseract.js (unsupported image formats like RAW/DNG) and shows helpful guidance: 'Use the 📸 live camera instead' - Falls through to actual error message for other failures - Better null-safety on error object --- static/index.html | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/static/index.html b/static/index.html index dbafdcd..fa695af 100644 --- a/static/index.html +++ b/static/index.html @@ -2649,7 +2649,14 @@ if (ocrEl) ocrEl.innerHTML = '❌ No machine ID detected. '; } } catch (ocrErr) { - if (ocrEl) ocrEl.textContent = '❌ OCR failed: ' + ocrErr.message; + if (ocrEl) { + const msg = ocrErr.message || ''; + if (msg.includes('unknown error') || msg === 'Client OCR failed: ') { + ocrEl.innerHTML = '❌ Photo format not supported by browser OCR. Use the 📸 live camera instead.'; + } else { + ocrEl.textContent = '❌ OCR failed: ' + msg; + } + } } // Extract GPS from EXIF @@ -3445,7 +3452,8 @@ result = await Promise.race([ocrPromise, timeoutPromise]); } catch (e) { updateOcrProgress({ status: 'error' }); - throw new Error('Client OCR failed: ' + (e.message || 'unknown error')); + const reason = (e && e.message) ? e.message : (e ? String(e) : 'image format not supported by browser'); + throw new Error('Client OCR failed: ' + reason); } updateOcrProgress({ status: 'done' });