Guvnor中的抛出异常(指导编辑器规则) [英] Throwing exception in Guvnor (Guided Editor Rule)

查看:141
本文介绍了Guvnor中的抛出异常(指导编辑器规则)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Guvnor构建规则项目.在我的DSL之一中,我遵循以下后果"声明来进行错误的操作:

I'm building a rules project using Guvnor. In one of my DSL, I've the follow "consequence" statement for wrong operations:

[when]Error "{message}"=throw new Exception( "{message}" );

如果我使用DSL规则,并用DSL语句编写所有规则,那么它会完美地工作.但是,使用引导式编辑器"无法正常工作,并且验证过程中会显示类似以下内容:

If I use the DSL rule, writing all the rule with DSL sentences, it works perfectly. However, using the Guided Editor, this doesn't work and the validation says anything like that:

[Error: unable to resolve method using strict-mode: org.drools.spi.KnowledgeHelper.throw()] [Near : {... throw new Exception( " ...

有人知道我需要为此做些什么?这很重要,因为我的项目将由非IT人员使用.

Someone knows what I need to do for this works? It's important because my project will be used by non-IT people.

谢谢.

Guided Editor生成的源代码非常简单:

The source code generated by the Guided Editor is very simple:

rule "exception test"
    dialect "mvel"
    when
        eval( true );
    then
        throw new Exception( "error message" );
end

推荐答案

问题不是使用DSL语句,而是使用'mvel'方言.看来Mvel不喜欢throw Exception语法. 解决方案是改用'java'方言.

The problem is not with the use of DSL sentences but with the use of 'mvel' dialect. It appears that Mvel doesn't like the throw Exception syntax. The solution is to use 'java' dialect instead.

为此,您必须在规则中添加'java'方言选项:

In order to do that, you must add 'java' dialect option in your rule:

不幸的是,据我所知,Govnor中没有全局设置默认使用'java'方言.

Unfortunately, as far as I remember, there is no global setting in Guvnor to use 'java' dialect by default.

这篇关于Guvnor中的抛出异常(指导编辑器规则)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆