fix crash in IG publisher rendering illegal content

This commit is contained in:
Grahame Grieve 2021-09-29 16:18:20 +10:00
parent 2df1283a54
commit 108bfe715b
1 changed files with 7 additions and 1 deletions

View File

@ -2,6 +2,7 @@ package org.hl7.fhir.r5.renderers.utils;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
@ -16,6 +17,7 @@ import org.hl7.fhir.r5.formats.IParser.OutputStyle;
import org.hl7.fhir.r5.model.Base;
import org.hl7.fhir.r5.model.ElementDefinition;
import org.hl7.fhir.r5.model.Narrative.NarrativeStatus;
import org.hl7.fhir.r5.model.StringType;
import org.hl7.fhir.r5.model.StructureDefinition;
import org.hl7.fhir.r5.renderers.ResourceRenderer;
import org.hl7.fhir.r5.renderers.utils.BaseWrappers.BaseWrapper;
@ -65,7 +67,11 @@ public class ElementWrappers {
if (context.getParser() == null) {
throw new Error("No type parser provided to renderer context");
} else {
return context.getParser().parseType(xml.toString(), type);
try {
return context.getParser().parseType(xml.toString(StandardCharsets.UTF_8), type);
} catch (Exception e) {
return new StringType("Illegal syntax: "+e.getMessage());
}
}
}