Replace IllegalStateException with ToolExecutionException for processor compatibility?
Replace IllegalStateException with ToolExecutionException for processor compatibility?
Expected Behavior
In order for this exception to be properly caught and handled by the ToolExecutionExceptionProcessor, I would like to know if it is feasible to change the thrown exception type to ToolExecutionException.
If changing it to ToolExecutionException is not the intended design, is there any alternative way to handle this specific IllegalStateException (e.g., via a custom handler, wrapping it, or configuring the existing processor to intercept it)?
Looking forward to your suggestions. Thanks!
Current Behavior
Currently, an IllegalStateException is thrown at this location instead of a ToolExecutionException.
spring-ai-model/src/main/java/org/springframework/ai/model/tool/DefaultToolCallingManager.java
if (toolCallback == null) {
if (logger.isWarnEnabled()) {
logger.warn(POSSIBLE_LLM_TOOL_NAME_CHANGE_WARNING_START + toolName
+ POSSIBLE_LLM_TOOL_NAME_CHANGE_WARNING_END);
}
throw new IllegalStateException("No ToolCallback found for tool name: " + toolName); // <--- Not ToolExecutionException
}Context
Source: spring-projects/spring-ai