feature #I6MPYF 增加CATCH语法表达式
This commit is contained in:
parent
d918e1c64b
commit
0efc040aaf
|
@ -28,15 +28,13 @@ public class CatchCondition extends Condition{
|
|||
catchExecutable.execute(slotIndex);
|
||||
}catch (Exception e){
|
||||
Executable doExecutable = this.getDoItem();
|
||||
if (ObjectUtil.isNull(doExecutable)){
|
||||
String errorInfo = StrUtil.format("[{}]:no catch do item find", slot.getRequestId());
|
||||
throw new CatchErrorException(errorInfo);
|
||||
if (ObjectUtil.isNotNull(doExecutable)){
|
||||
doExecutable.setCurrChainId(this.getCurrChainId());
|
||||
doExecutable.execute(slotIndex);
|
||||
//catch之后需要把exception给清除掉
|
||||
//正如同java的catch一样,异常自己处理了,属于正常流程了,整个流程状态应该是成功的
|
||||
DataBus.getSlot(slotIndex).removeException();
|
||||
}
|
||||
doExecutable.setCurrChainId(this.getCurrChainId());
|
||||
doExecutable.execute(slotIndex);
|
||||
//catch之后需要把exception给清除掉
|
||||
//正如同java的catch一样,异常自己处理了,属于正常流程了,整个流程状态应该是成功的
|
||||
DataBus.getSlot(slotIndex).removeException();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -42,4 +42,18 @@ public class CatchELSpringbootTest extends BaseTest {
|
|||
Assert.assertFalse(response.isSuccess());
|
||||
Assert.assertEquals("a==>d", response.getExecuteStepStrWithoutTime());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCatch3() throws Exception{
|
||||
LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg");
|
||||
Assert.assertFalse(response.isSuccess());
|
||||
Assert.assertEquals("a", response.getExecuteStepStrWithoutTime());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCatch4() throws Exception{
|
||||
LiteflowResponse response = flowExecutor.execute2Resp("chain4", "arg");
|
||||
Assert.assertFalse(response.isSuccess());
|
||||
Assert.assertEquals("LOOP_3==>a==>b==>a==>b==>a==>b", response.getExecuteStepStrWithoutTime());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
/**
|
||||
* <p>Title: liteflow</p>
|
||||
* <p>Description: 轻量级的组件式流程框架</p>
|
||||
* @author Bryan.Zhang
|
||||
* @email weenyc31@163.com
|
||||
* @Date 2020/4/1
|
||||
*/
|
||||
package com.yomahub.liteflow.test.catchcase.cmp;
|
||||
|
||||
import com.yomahub.liteflow.core.NodeComponent;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component("e")
|
||||
public class ECmp extends NodeComponent {
|
||||
|
||||
@Override
|
||||
public void process() {
|
||||
System.out.println("ECmp executed!");
|
||||
}
|
||||
|
||||
}
|
|
@ -12,4 +12,18 @@
|
|||
THEN(a,b)
|
||||
).DO(d)
|
||||
</chain>
|
||||
|
||||
<chain name="chain3">
|
||||
CATCH(
|
||||
THEN(a,b)
|
||||
);
|
||||
</chain>
|
||||
|
||||
<chain name="chain4">
|
||||
FOR(3).DO(
|
||||
CATCH(
|
||||
THEN(a,e,FINALLY(b))
|
||||
)
|
||||
);
|
||||
</chain>
|
||||
</flow>
|
Loading…
Reference in New Issue