better error messages setting properties when transforming

This commit is contained in:
Grahame Grieve 2023-03-17 07:55:53 +11:00
parent d9c632d9ad
commit 72d97a2960
1 changed files with 7 additions and 2 deletions

View File

@ -1719,8 +1719,13 @@ public class StructureMapUtilities {
Base v = null;
if (tgt.hasTransform()) {
v = runTransform(rulePath, context, map, group, tgt, vars, dest, tgt.getElement(), srcVar, atRoot);
if (v != null && dest != null)
v = dest.setProperty(tgt.getElement().hashCode(), tgt.getElement(), v); // reset v because some implementations may have to rewrite v when setting the value
if (v != null && dest != null) {
try {
v = dest.setProperty(tgt.getElement().hashCode(), tgt.getElement(), v); // reset v because some implementations may have to rewrite v when setting the value
} catch (Exception e) {
throw new FHIRException("Error setting "+tgt.getElement()+" on "+dest.fhirType()+" for rule "+rulePath+" to value "+v.toString()+": "+e.getMessage(), e);
}
}
} else if (dest != null) {
if (tgt.hasListMode(StructureMapTargetListMode.SHARE)) {
v = sharedVars.get(VariableMode.SHARED, tgt.getListRuleId());