Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
开发团队
Flowable Engine
提交
bfd328cb
F
Flowable Engine
项目概览
开发团队
/
Flowable Engine
通知
9
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
F
Flowable Engine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
bfd328cb
编写于
1月 20, 2012
作者:
F
falko.menge
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
ACT-1021 User Guide: Documented how to trigger BPMN Errors from JavaDelegates
上级
cb113b40
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
61 addition
and
10 deletion
+61
-10
userguide/src/en/chapters/ch07-BPMN.xml
userguide/src/en/chapters/ch07-BPMN.xml
+61
-10
未找到文件。
userguide/src/en/chapters/ch07-BPMN.xml
浏览文件 @
bfd328cb
...
...
@@ -2355,12 +2355,62 @@ public class ReverseStringsFieldInjected implements JavaDelegate {
<section
id=
"serviceTaskExceptionHandling"
>
<title>
Handling exceptions
</title>
<para>
When custom logic is executed, it is often required to catch certain
business exceptions and handle them inside the surrounding process.
Activiti provides different options to do that.
</para>
<para>
When custom logic is executed, it is often required to catch certain exceptions.
One common use case is to route process execution through another path
in case some exception occurs. The following example shows how this is done.
<programlisting>
<section
id=
"serviceTaskBpmnErrors"
>
<title>
Throwing BPMN Errors
</title>
<para>
As of Activiti 5.9, it is possible to throw BPMN Errors from user code
inside Service Tasks or Script Tasks.
In order to do this, a special ActivitiException called
<emphasis>
BpmnError
</emphasis>
can be thrown in JavaDelegates or scripts.
The engine will catch this exception and forward it to an appropriate
error handler, e.g., a Boundary Error Event or an Error Event Sub-Process.
<programlisting>
public class ThrowBpmnErrorDelegate implements JavaDelegate {
public void execute(DelegateExecution execution) throws Exception {
try {
executeBusinessLogic();
} catch (BusinessExeption e) {
throw new BpmnError(
"
BusinessExeptionOccured
"
);
}
}
}
</programlisting>
The constructor argument is an error code, which will be used to
determine the error handler that is responsible for the error.
See
<link
linkend=
"bpmnBoundaryErrorEvent"
>
Boundary Error Event
</link>
for information on how to catch a BPMN Error.
</para>
<para>
This mechanism should be used
<emphasis
role=
"bold"
>
only for business faults
</emphasis>
that shall be handled by a Boundary Error Event or Error Event Sub-Process
modeled in the process definition.
Technical errors should be represented by other exception types
and are usually not handled inside a process.
</para>
</section>
<section
id=
"serviceTaskExceptionSequenceFlow"
>
<title>
Exception Sequence Flow
</title>
<para>
<link
linkend=
"internal"
>
<emphasis
role=
"bold"
>
[INTERNAL: non-public implementation classes]
</emphasis>
</link>
Another option is to route process execution through another path
in case some exception occurs. The following example shows how this is done.
<programlisting>
<
serviceTask id=
"
javaService
"
name=
"
Java service invocation
"
activiti:class=
"
org.activiti.ThrowsExceptionBehavior
">
...
...
@@ -2368,10 +2418,10 @@ public class ReverseStringsFieldInjected implements JavaDelegate {
<
sequenceFlow id=
"
no-exception
"
sourceRef=
"
javaService
"
targetRef=
"
theEnd
"
/
>
<
sequenceFlow id=
"
exception
"
sourceRef=
"
javaService
"
targetRef=
"
fixException
"
/
>
</programlisting>
Here, the service task has two outgoing sequence flow, called
<literal>
exception
</literal>
and
<literal>
no-exception
</literal>
. This sequence flow id will be used to direct
process flow in case of an exception:
<programlisting>
Here, the service task has two outgoing sequence flow, called
<literal>
exception
</literal>
and
<literal>
no-exception
</literal>
. This sequence flow id will be used to direct
process flow in case of an exception:
<programlisting>
public class ThrowsExceptionBehavior implements ActivityBehavior {
public void execute(ActivityExecution execution) throws Exception {
...
...
@@ -2388,7 +2438,8 @@ public class ThrowsExceptionBehavior implements ActivityBehavior {
}
}
</programlisting>
</para>
</para>
</section>
</section>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录