Interface ToolArgumentsErrorHandler

Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface ToolArgumentsErrorHandler
Handler for ToolArgumentsExceptions thrown by a ToolExecutor.

There are two ways to handle errors:

1. Return a text message that will be sent back to the LLM, allowing it to respond appropriately (for example, by correcting the error and retrying).

2. Throw an exception: this will stop the AI service flow. Use ToolErrorContext.rawError() to access the raw error before cause-unwrapping when deciding whether to throw.

Since:
1.4.0
See Also:
  • Method Details

    • handle

      Handles an error that occurred during the parsing and preparation of tool arguments.

      This method should either throw an exception or return a ToolErrorHandlerResult.text(String), which will be sent to the LLM as the result of the tool execution.

      Parameters:
      error - The actual error that occurred (cause-unwrapped). Use ToolErrorContext.rawError() for the error before unwrapping.
      context - The context in which the error occurred.
      Returns:
      The result of error handling.