Skip to content
This repository has been archived by the owner on Nov 30, 2021. It is now read-only.

Commit

Permalink
DROOLS-1432: improving error message handling
Browse files Browse the repository at this point in the history
  • Loading branch information
etirelli committed Feb 26, 2017
1 parent ade78de commit e588c54
Showing 1 changed file with 5 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -46,7 +43,6 @@
import java.io.Reader;
import java.util.List;

import static java.util.stream.Collectors.toList;

public class DMNCompilerImpl
implements DMNCompiler {
Expand Down Expand Up @@ -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 );
}
Expand Down Expand Up @@ -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;
}
Expand Down

2 comments on commit e588c54

@manstis
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought you externalised error messages (for i18n when we write the UI)?

@etirelli
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@manstis not yet. On the FEEL layer and on the Validator they are consolidated in a single class, but on the DMN layer, we still have to do that. Then we need to actually create the i18n resources.

Here are the classes for the FEEL layer and the Validator:

https://github.com/droolsjbpm/kie-dmn/blob/master/kie-dmn-feel/src/main/java/org/kie/dmn/feel/util/Msg.java

https://github.com/droolsjbpm/kie-dmn/blob/master/kie-dmn-validation/src/main/java/org/kie/dmn/validation/Msg.java

We will do the same for the DMN layer on a following ticket. This ticket's main purpose was to fix the "communication" between the FEEL layer and the DMN layer.

Please sign in to comment.