Class A2AErrorResponse

java.lang.Object
org.a2aproject.sdk.jsonrpc.common.wrappers.A2AResponse<Void>
org.a2aproject.sdk.jsonrpc.common.wrappers.A2AErrorResponse
All Implemented Interfaces:
A2AMessage

public final class A2AErrorResponse extends A2AResponse<Void>
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 - A A2AError object describing the error
  • id - 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:
  • 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 request
      result - must be null for error responses
      error - the error object describing what went wrong (required)
      Throws:
      IllegalArgumentException - if error is null
    • A2AErrorResponse

      public A2AErrorResponse(Object id, org.a2aproject.sdk.spec.A2AError error)
      Constructs a JSON-RPC error response with a request ID and error.

      The jsonrpc field defaults to "2.0".

      Parameters:
      id - the request ID
      error - 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)