From e588c54947fd33e1f0ffb8e6116a7449b2823388 Mon Sep 17 00:00:00 2001 From: Edson Tirelli Date: Sun, 26 Feb 2017 18:09:58 -0500 Subject: [PATCH] DROOLS-1432: improving error message handling --- .../org/kie/dmn/core/compiler/DMNCompilerImpl.java | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/kie-dmn-core/src/main/java/org/kie/dmn/core/compiler/DMNCompilerImpl.java b/kie-dmn-core/src/main/java/org/kie/dmn/core/compiler/DMNCompilerImpl.java index 7bfb207..c2799d6 100644 --- a/kie-dmn-core/src/main/java/org/kie/dmn/core/compiler/DMNCompilerImpl.java +++ b/kie-dmn-core/src/main/java/org/kie/dmn/core/compiler/DMNCompilerImpl.java @@ -26,14 +26,11 @@ import org.kie.dmn.api.core.ast.DMNNode; import org.kie.dmn.api.core.ast.DecisionNode; import org.kie.dmn.api.core.ast.InputDataNode; -import org.kie.dmn.api.core.ast.ItemDefNode; import org.kie.dmn.backend.marshalling.v1_1.DMNMarshallerFactory; import org.kie.dmn.core.ast.*; import org.kie.dmn.core.impl.BaseDMNTypeImpl; import org.kie.dmn.core.impl.CompositeTypeImpl; import org.kie.dmn.core.impl.DMNModelImpl; -import org.kie.dmn.core.impl.SimpleTypeImpl; -import org.kie.dmn.feel.lang.Type; import org.kie.dmn.feel.lang.types.BuiltInType; import org.kie.dmn.feel.model.v1_1.*; import org.kie.dmn.feel.parser.feel11.FEELParser; @@ -46,7 +43,6 @@ import java.io.Reader; import java.util.List; -import static java.util.stream.Collectors.toList; public class DMNCompilerImpl implements DMNCompiler { @@ -130,7 +126,6 @@ private void processDrgElements(DMNCompilerContext ctx, DMNFEELHelper feel, DMNM if ( bkm.getVariable() != null && bkm.getVariable().getTypeRef() != null ) { type = resolveTypeRef( model, bkmn, bkm, bkm.getVariable(), bkm.getVariable().getTypeRef() ); } else { - // TODO: need to handle cases where the variable is not defined or does not have a type; // for now the call bellow will return type UNKNOWN type = resolveTypeRef( model, bkmn, bkm, bkm, null ); } @@ -295,11 +290,14 @@ public DMNType resolveTypeRef(DMNModelImpl dmnModel, DMNNode node, NamedElement } } } else if( type == null ) { + String errorMsg = null; if ( model.getName() != null && node.getName() != null && model.getName().equals( node.getName() ) ) { - logger.error( "No '" + typeRef.toString() + "' type definition found for node '" + node.getName() + "'" ); + errorMsg = "No '" + typeRef.toString() + "' type definition found for node '" + node.getName() + "'"; } else { - logger.error( "No '" + typeRef.toString() + "' type definition found for element '" + model.getName() + "' on node '" + node.getName() + "'" ); + errorMsg = "No '" + typeRef.toString() + "' type definition found for element '" + model.getName() + "' on node '" + node.getName() + "'"; } + logger.error( errorMsg ); + dmnModel.addMessage( DMNMessage.Severity.ERROR, errorMsg, node.getId() ); } return type; }