mirror of
https://gitee.com/agents-flex/agents-flex.git
synced 2024-12-01 19:37:50 +08:00
refactor: optimize Chain.executeForResult() method
This commit is contained in:
parent
ca6385776e
commit
d005dcb283
@ -192,7 +192,14 @@ public class Chain extends ChainNode {
|
||||
|
||||
|
||||
public Map<String, Object> executeForResult(Map<String, Object> variables) {
|
||||
|
||||
runInLifeCycle(variables, this::executeInternal);
|
||||
|
||||
if (this.status == ChainStatus.FINISHED_ABNORMAL) {
|
||||
if (this.message == null) this.message = "Chain execute error";
|
||||
throw new ChainException(this.message);
|
||||
}
|
||||
|
||||
return this.executeResult;
|
||||
}
|
||||
|
||||
|
@ -15,21 +15,19 @@
|
||||
*/
|
||||
package com.agentsflex.core.chain;
|
||||
|
||||
import java.security.PrivilegedActionException;
|
||||
|
||||
public class ChainException extends Exception {
|
||||
public class ChainException extends RuntimeException {
|
||||
/**
|
||||
* Constructs a new exception with {@code null} as its detail message.
|
||||
* The cause is not initialized, and may subsequently be initialized by a
|
||||
* call to {@link #initCause}.
|
||||
* Constructs a new runtime exception with {@code null} as its
|
||||
* detail message. The cause is not initialized, and may subsequently be
|
||||
* initialized by a call to {@link #initCause}.
|
||||
*/
|
||||
public ChainException() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new exception with the specified detail message. The
|
||||
* cause is not initialized, and may subsequently be initialized by
|
||||
* a call to {@link #initCause}.
|
||||
* Constructs a new runtime exception with the specified detail message.
|
||||
* The cause is not initialized, and may subsequently be initialized by a
|
||||
* call to {@link #initCause}.
|
||||
*
|
||||
* @param message the detail message. The detail message is saved for
|
||||
* later retrieval by the {@link #getMessage()} method.
|
||||
@ -39,10 +37,10 @@ public class ChainException extends Exception {
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new exception with the specified detail message and
|
||||
* Constructs a new runtime exception with the specified detail message and
|
||||
* cause. <p>Note that the detail message associated with
|
||||
* {@code cause} is <i>not</i> automatically incorporated in
|
||||
* this exception's detail message.
|
||||
* this runtime exception's detail message.
|
||||
*
|
||||
* @param message the detail message (which is saved for later retrieval
|
||||
* by the {@link #getMessage()} method).
|
||||
@ -57,12 +55,11 @@ public class ChainException extends Exception {
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new exception with the specified cause and a detail
|
||||
* message of <tt>(cause==null ? null : cause.toString())</tt> (which
|
||||
* typically contains the class and detail message of <tt>cause</tt>).
|
||||
* This constructor is useful for exceptions that are little more than
|
||||
* wrappers for other throwables (for example, {@link
|
||||
* PrivilegedActionException}).
|
||||
* Constructs a new runtime exception with the specified cause and a
|
||||
* detail message of <tt>(cause==null ? null : cause.toString())</tt>
|
||||
* (which typically contains the class and detail message of
|
||||
* <tt>cause</tt>). This constructor is useful for runtime exceptions
|
||||
* that are little more than wrappers for other throwables.
|
||||
*
|
||||
* @param cause the cause (which is saved for later retrieval by the
|
||||
* {@link #getCause()} method). (A <tt>null</tt> value is
|
||||
@ -75,9 +72,9 @@ public class ChainException extends Exception {
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new exception with the specified detail message,
|
||||
* cause, suppression enabled or disabled, and writable stack
|
||||
* trace enabled or disabled.
|
||||
* Constructs a new runtime exception with the specified detail
|
||||
* message, cause, suppression enabled or disabled, and writable
|
||||
* stack trace enabled or disabled.
|
||||
*
|
||||
* @param message the detail message.
|
||||
* @param cause the cause. (A {@code null} value is permitted,
|
||||
|
Loading…
Reference in New Issue
Block a user