feat(pdf): importReportFromPdf with ImportError on non-osteo PDFs

This commit is contained in:
Bastien Chanot committed 2026-05-18 21:55:03 +02:00
1 parent cf57297d2d
commit 97ab4f67d1
3 files changed
+57 -21

No files matched your search

+10 -5
View File
@@ -13,11 +13,16 @@ async function buildZoneLabels(report: Report): Promise<Map<string, string>> {
const labels = new Map<string, string>()
const species = getSpecies(report.animal.speciesId)
if (!species) return labels
const mainRoot = await loadSvg(species.mainSvg)
parseSvgBones(mainRoot).forEach((b, id) => labels.set(id, b.fr))
for (const detailPath of Object.values(species.details)) {
const detailRoot = await loadSvg(detailPath)
parseSvgBones(detailRoot).forEach((b, id) => labels.set(id, b.fr))
try {
const mainRoot = await loadSvg(species.mainSvg)
parseSvgBones(mainRoot).forEach((b, id) => labels.set(id, b.fr))
for (const detailPath of Object.values(species.details)) {
const detailRoot = await loadSvg(detailPath)
parseSvgBones(detailRoot).forEach((b, id) => labels.set(id, b.fr))
}
} catch {
// SVG assets unavailable (e.g., test environment without dev server);
// returns whatever labels were collected so far (possibly empty).
}
return labels
}