🧊Exceptions
In the LiteFlow component, if an exception is thrown out, the chain will be interrupted. Except for setting the ignoreError
keyword in Parallel mode.
Outgoing exceptions are caught by the executor and wrapped in a LiteflowResponse
object.
You can get exceptions in the LiteflowResponse
object using the following methods
LiteflowResponse response = flowExecutor.execute2Resp("chain1", initial parameters, CustomContext.class);
if (!response.isSuccess()){
Exception e = response.getCause();
}
If your business needs to obtain the exception code, your custom exception needs to implement the LiteFlowException
interface provided by LiteFlow:
public class YourException extends LiteFlowException {
public YourException(String code, String message) {
super(code, message);
}
}
If your business throws an exception that implements the LiteFlowException
interface, you can get the message and code information in the LiteflowResponse
:
LiteflowResponse response = flowExecutor.execute2Resp("chain1", 初始参数, CustomContext.class);
if (!response.isSuccess()){
Exception e = response.getCause();
String code = response.getCode();
String message = response.getMessage();
}
tip
If your exception does not implement LiteFlowException
, the code and message fields are both null.
Help us improve this document (opens new window)
last update: 2022/10/13, 00:02:27