Package com.tnsai.exceptions
Class ActionExecutionException
java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
com.tnsai.exceptions.TnsAIException
com.tnsai.exceptions.ActionExecutionException
- All Implemented Interfaces:
Serializable
Exception thrown when action execution fails.
Provides detailed error context including action type, name, and whether the error is retryable.
This exception preserves the full exception context (type, message, cause) to enable: - Better debugging with full stack traces - Intelligent retry logic based on error type - LLM understanding of what went wrong
Example Usage:
try {
Object result = executeAction(action, params);
} catch (ActionExecutionException e) {
if (e.isRetryable()) {
// Retry with exponential backoff
retryWithBackoff(action, params);
} else {
// Log and fail permanently
logger.error("Non-retryable error: {}", e.getMessage());
}
}
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumError categories for action execution failures. -
Constructor Summary
ConstructorsConstructorDescriptionActionExecutionException(String message) Creates an ActionExecutionException with full context.ActionExecutionException(String message, Throwable cause) ActionExecutionException(String message, Throwable cause, String actionName, ActionType actionType) Creates an ActionExecutionException with unknown category.ActionExecutionException(String message, Throwable cause, String actionName, ActionType actionType, ActionExecutionException.ErrorCategory category) Creates an ActionExecutionException with default retryable flag from category.ActionExecutionException(String message, Throwable cause, String actionName, ActionType actionType, ActionExecutionException.ErrorCategory category, boolean retryable) -
Method Summary
Modifier and TypeMethodDescriptionstatic ActionExecutionExceptionfromApiError(String actionName, ActionType actionType, int statusCode, String responseMessage, Throwable cause) Factory method to create exception from API errors (with HTTP status code).static ActionExecutionExceptionfromInvocationError(String actionName, ActionType actionType, Exception cause) Factory method to create exception from invocation errors (reflection, etc.).static ActionExecutionExceptionfromLLMError(String actionName, ActionType actionType, Exception cause) Factory method to create exception from LLM errors.static ActionExecutionExceptionfromMCPError(String actionName, Exception cause) Factory method to create exception from MCP tool errors.static ActionExecutionExceptionfromNetworkError(String actionName, ActionType actionType, Exception cause) Factory method to create exception from IOException (network errors).static ActionExecutionExceptionfromParameterError(String actionName, ActionType actionType, String details, Throwable cause) Factory method to create exception from parameter validation errors.Gets the name of the action that failed.Gets the type of the action that failed.Gets the error category.Gets a detailed error message suitable for logging or LLM consumption.booleanChecks if this error is retryable.Methods inherited from class com.tnsai.exceptions.TnsAIException
getContext, getErrorCode, getMaxRetryAttempts, getMessage, getSuggestedRetryDelayMs, getThrownAt, wrapMethods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
-
Constructor Details
-
ActionExecutionException
Creates an ActionExecutionException with full context.- Parameters:
message- Error messagecause- Original exception that caused the failureactionName- Name of the action that failedactionType- Type of the action (LOCAL, WEB_SERVICE, LLM, etc.)category- Error category for classificationretryable- Whether this error can be retried
-
ActionExecutionException
-
ActionExecutionException
public ActionExecutionException(String message, Throwable cause, String actionName, ActionType actionType, ActionExecutionException.ErrorCategory category, boolean retryable) -
ActionExecutionException
public ActionExecutionException(String message, Throwable cause, String actionName, ActionType actionType, ActionExecutionException.ErrorCategory category) Creates an ActionExecutionException with default retryable flag from category.- Parameters:
message- Error messagecause- Original exception that caused the failureactionName- Name of the action that failedactionType- Type of the actioncategory- Error category for classification
-
ActionExecutionException
public ActionExecutionException(String message, Throwable cause, String actionName, ActionType actionType) Creates an ActionExecutionException with unknown category.- Parameters:
message- Error messagecause- Original exception that caused the failureactionName- Name of the action that failedactionType- Type of the action
-
-
Method Details
-
getActionName
Gets the name of the action that failed.- Returns:
- Action name
-
getActionType
Gets the type of the action that failed.- Returns:
- Action type
-
getCategory
Gets the error category.- Returns:
- Error category
-
isRetryable
public boolean isRetryable()Checks if this error is retryable.- Overrides:
isRetryablein classTnsAIException- Returns:
- true if the operation can be retried, false otherwise
-
getDetailedMessage
Gets a detailed error message suitable for logging or LLM consumption.- Returns:
- Formatted error message with full context
-
fromNetworkError
public static ActionExecutionException fromNetworkError(String actionName, ActionType actionType, Exception cause) Factory method to create exception from IOException (network errors). -
fromParameterError
public static ActionExecutionException fromParameterError(String actionName, ActionType actionType, String details, Throwable cause) Factory method to create exception from parameter validation errors. -
fromApiError
public static ActionExecutionException fromApiError(String actionName, ActionType actionType, int statusCode, String responseMessage, Throwable cause) Factory method to create exception from API errors (with HTTP status code). -
fromLLMError
public static ActionExecutionException fromLLMError(String actionName, ActionType actionType, Exception cause) Factory method to create exception from LLM errors. -
fromMCPError
Factory method to create exception from MCP tool errors. -
fromInvocationError
public static ActionExecutionException fromInvocationError(String actionName, ActionType actionType, Exception cause) Factory method to create exception from invocation errors (reflection, etc.).
-