gallery upload: better OCR error messages

- 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
This commit is contained in:
2026-05-21 14:47:34 -04:00
parent 78c3c19ce4
commit 97699a95ea
+10 -2
View File
@@ -2649,7 +2649,14 @@
if (ocrEl) ocrEl.innerHTML = '❌ No machine ID detected. <button class="btn btn-outline btn-sm" onclick="document.getElementById(\'scanMachineId\').value=prompt(\'Enter machine ID:\');handleBarcode(document.getElementById(\'scanMachineId\').value)">Enter manually</button>';
}
} 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' });