-
Notifications
You must be signed in to change notification settings - Fork 124
Description
Is your feature request related to a problem? Please describe.
Hello, I ran into the following problem:
I am implementing a customized JSONRPC server, where I use DefaultRequestHandler, JSONRPCHandler from this project, and implemented a customized AgentExecutor.
When I am debuging the SendStreamingMessage method, I throw an UnsupportedOperationError from MyAgentExecutor, but got a -32603 InternalError from the SendStreamingMessageResponse.
It seems that in this function,
a2a-java/transport/jsonrpc/src/main/java/io/a2a/transport/jsonrpc/handler/JSONRPCHandler.java
Line 305 in 7bf82c6
| public void onError(Throwable throwable) { |
it receives a java.util.concurrent.CompletionException, instead of the UnsupportedOperationError.
Describe the solution you'd like
It seems that the CompletionException has the UnsupportedOperationError as the cause field.
I am wondering if it is reasonable to also check for the cause field of the throwable, to see if it is an instance of the A2AError class. If it is, send the according response.
Something like:
@Override
public void onError(Throwable throwable) {
if (throwable instanceof A2AError jsonrpcError) {
tube.send(new SendStreamingMessageResponse(requestId, jsonrpcError));
} else if (throwable.getCause() != null && throwable.getCause() instanceof A2AError jsonrpcError) { // also check the cause field
tube.send(new SendStreamingMessageResponse(requestId, jsonrpcError));
} else {
tube.send(
new SendStreamingMessageResponse(
requestId, new
InternalError(throwable.getMessage())));
}
onComplete();
}
It would be helpful if you can take a look. Thanks!
Describe alternatives you've considered
No response
Additional context
No response
Code of Conduct
- I agree to follow this project's Code of Conduct