fix for NPE rendering resources

This commit is contained in:
Grahame Grieve 2023-01-31 07:23:12 +11:00
parent d859e0b4bd
commit 7ad4bd62c6
2 changed files with 7 additions and 3 deletions

View File

@ -696,7 +696,7 @@ public class ProfileDrivenRenderer extends ResourceRenderer {
}
private boolean isBase(String code) {
return code.equals("Element") || code.equals("BackboneElement");
return code != null && (code.equals("Element") || code.equals("BackboneElement"));
}
private List<ElementDefinition> getChildrenForPath(StructureDefinition profile, List<ElementDefinition> elements, String path) throws DefinitionException {
@ -1008,7 +1008,11 @@ public class ProfileDrivenRenderer extends ResourceRenderer {
// we're going to split these up, and create a property for each url
if (p.hasValues()) {
for (BaseWrapper v : p.getValues()) {
Extension ex = (Extension) v.getBase();
Base b = v.getBase();
if (!(b instanceof Extension)) {
throw new FHIRException("huh?");
}
Extension ex = (Extension) b;
String url = ex.getUrl();
StructureDefinition ed = getContext().getWorker().fetchResource(StructureDefinition.class, url);
if (ed == null) {

View File

@ -69,7 +69,7 @@ public class ElementWrappers {
try {
return context.getParser().parseType(xml.toString(StandardCharsets.UTF_8), type);
} catch (Exception e) {
return new StringType("Illegal syntax: "+e.getMessage());
throw new FHIRException(e.getMessage(), e);
}
}
}