Action Exception
Base class for action execution exceptions with built-in retry classification.
Provides convenient base classes for retryable and non-retryable exceptions without requiring users to implement marker interfaces directly.
This class is open to allow users to create domain-specific exception hierarchies:
import com.embabel.agent.core.ActionException
// Extend ActionException for domain-specific exceptions
class ValidationException(message: String)
: ActionException.Permanent(message)
class ApiTimeoutException(message: String, cause: Throwable? = null)
: ActionException.Transient(message, cause)
// Or implement marker interfaces directly
import com.embabel.agent.core.NonRetryable
import com.embabel.agent.core.Retryable
class CustomValidationError(message: String)
: RuntimeException(message), NonRetryable
class CustomTimeoutError(message: String)
: RuntimeException(message), RetryableContent copied to clipboard
Example usage:
import com.embabel.agent.core.ActionException;
@Action
public Result processOrder(Order order) {
if (!order.isValid()) {
// Won't be retried
throw new ActionException.Permanent("Invalid order: " + order.id);
}
try {
return externalApi.submit(order);
} catch (TimeoutException e) {
// Will be retried
throw new ActionException.Transient("API timeout", e);
}
}Content copied to clipboard