Class ActionExecutionException

All Implemented Interfaces:
Serializable

public class ActionExecutionException extends TnsAIException
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:
  • Constructor Details

    • ActionExecutionException

      public ActionExecutionException(String message)
      Creates an ActionExecutionException with full context.
      Parameters:
      message - Error message
      cause - Original exception that caused the failure
      actionName - Name of the action that failed
      actionType - Type of the action (LOCAL, WEB_SERVICE, LLM, etc.)
      category - Error category for classification
      retryable - Whether this error can be retried
    • ActionExecutionException

      public ActionExecutionException(String message, Throwable cause)
    • 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 message
      cause - Original exception that caused the failure
      actionName - Name of the action that failed
      actionType - Type of the action
      category - Error category for classification
    • ActionExecutionException

      public ActionExecutionException(String message, Throwable cause, String actionName, ActionType actionType)
      Creates an ActionExecutionException with unknown category.
      Parameters:
      message - Error message
      cause - Original exception that caused the failure
      actionName - Name of the action that failed
      actionType - Type of the action
  • Method Details

    • getActionName

      public String getActionName()
      Gets the name of the action that failed.
      Returns:
      Action name
    • getActionType

      public ActionType 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:
      isRetryable in class TnsAIException
      Returns:
      true if the operation can be retried, false otherwise
    • getDetailedMessage

      public String 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

      public static ActionExecutionException fromMCPError(String actionName, Exception cause)
      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.).