Class A2AErrorResponse
java.lang.Object
org.a2aproject.sdk.jsonrpc.common.wrappers.A2AResponse<Void>
org.a2aproject.sdk.jsonrpc.common.wrappers.A2AErrorResponse
- All Implemented Interfaces:
A2AMessage
Represents a JSON-RPC 2.0 error response.
An error response is returned when a request cannot be processed successfully. According to the JSON-RPC 2.0 specification, an error response must contain:
jsonrpc- Always "2.0"error- AA2AErrorobject describing the errorid- The request ID, or null if the ID could not be determined
The result field must be absent or null in error responses. This class
enforces that constraint by fixing the result type parameter to Void.
- See Also:
-
A2AErrorA2AResponse- JSON-RPC 2.0 Response Object
-
Field Summary
Fields inherited from class org.a2aproject.sdk.jsonrpc.common.wrappers.A2AResponse
error, id, jsonrpc, resultFields inherited from interface org.a2aproject.sdk.jsonrpc.common.wrappers.A2AMessage
JSONRPC_VERSION -
Constructor Summary
ConstructorsConstructorDescriptionA2AErrorResponse(Object id, org.a2aproject.sdk.spec.A2AError error) Constructs a JSON-RPC error response with a request ID and error.A2AErrorResponse(String jsonrpc, Object id, Void result, org.a2aproject.sdk.spec.A2AError error) Constructs a JSON-RPC error response with all fields.A2AErrorResponse(org.a2aproject.sdk.spec.A2AError error) Constructs a JSON-RPC error response without a request ID. -
Method Summary
Methods inherited from class org.a2aproject.sdk.jsonrpc.common.wrappers.A2AResponse
getError, getId, getJsonrpc, getResult
-
Constructor Details
-
A2AErrorResponse
public A2AErrorResponse(String jsonrpc, Object id, Void result, org.a2aproject.sdk.spec.A2AError error) Constructs a JSON-RPC error response with all fields.This constructor is used for JSON deserialization.
- Parameters:
jsonrpc- the JSON-RPC version (must be "2.0")id- the request ID, or null if the ID could not be determined from the requestresult- must be null for error responseserror- the error object describing what went wrong (required)- Throws:
IllegalArgumentException- if error is null
-
A2AErrorResponse
Constructs a JSON-RPC error response with a request ID and error.The jsonrpc field defaults to "2.0".
- Parameters:
id- the request IDerror- the error object (required)
-
A2AErrorResponse
public A2AErrorResponse(org.a2aproject.sdk.spec.A2AError error) Constructs a JSON-RPC error response without a request ID.Use this constructor when the request ID could not be determined, typically for parse errors or malformed requests.
- Parameters:
error- the error object (required)
-