Search in sources :

Example 6 with DroolsParserException

use of org.drools.compiler.compiler.DroolsParserException in project drools by kiegroup.

the class DroolsParserExceptionFactory method createDroolsException.

public DroolsParserException createDroolsException(Exception e, Token token) {
    StringWriter sw = new StringWriter();
    e.printStackTrace(new PrintWriter(sw));
    return new DroolsParserException(String.format(DroolsParserExceptionFactory.UNEXPECTED_EXCEPTION, token.getLine(), token.getCharPositionInLine(), getBetterToken(token), e.toString(), sw.toString()), e);
}
Also used : StringWriter(java.io.StringWriter) DroolsParserException(org.drools.compiler.compiler.DroolsParserException) PrintWriter(java.io.PrintWriter)

Example 7 with DroolsParserException

use of org.drools.compiler.compiler.DroolsParserException in project drools-wb by kiegroup.

the class FactModelPersistence method unmarshal.

public static FactModels unmarshal(final String content) {
    try {
        // De-serialize model
        final List<FactMetaModel> models = toModel(content);
        final FactModels factModels = new FactModels();
        factModels.getModels().addAll(models);
        // De-serialize Package name
        final String packageName = PackageNameParser.parsePackageName(content);
        factModels.setPackageName(packageName);
        // De-serialize imports
        final Imports imports = ImportsParser.parseImports(content);
        factModels.setImports(imports);
        return factModels;
    } catch (final DroolsParserException e) {
        throw new RuntimeException(e);
    }
// TODO {porcelli} needs define error handling strategy
// log.error( "Unable to parse the DRL for the model - falling back to text (" + e.getMessage() + ")" );
// RuleContentText text = new RuleContentText();
// text.content = item.getContent();
// asset.setContent( text );
}
Also used : FactMetaModel(org.drools.workbench.screens.factmodel.model.FactMetaModel) Imports(org.kie.soup.project.datamodel.imports.Imports) FactModels(org.drools.workbench.screens.factmodel.model.FactModels) DroolsParserException(org.drools.compiler.compiler.DroolsParserException)

Aggregations

DroolsParserException (org.drools.compiler.compiler.DroolsParserException)7 DrlParser (org.drools.compiler.compiler.DrlParser)3 PackageDescr (org.drools.compiler.lang.descr.PackageDescr)3 StringReader (java.io.StringReader)2 FactMetaModel (org.drools.workbench.screens.factmodel.model.FactMetaModel)2 Test (org.junit.Test)2 IOException (java.io.IOException)1 PrintWriter (java.io.PrintWriter)1 StringWriter (java.io.StringWriter)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Dialect (org.drools.compiler.compiler.Dialect)1 DialectCompiletimeRegistry (org.drools.compiler.compiler.DialectCompiletimeRegistry)1 DuplicateProcess (org.drools.compiler.compiler.DuplicateProcess)1 PackageRegistry (org.drools.compiler.compiler.PackageRegistry)1 ParserError (org.drools.compiler.compiler.ParserError)1 AnnotationDescr (org.drools.compiler.lang.descr.AnnotationDescr)1 PatternDescr (org.drools.compiler.lang.descr.PatternDescr)1 ProcessDescr (org.drools.compiler.lang.descr.ProcessDescr)1