Class A2AClientHTTPError

All Implemented Interfaces:
Serializable

public class A2AClientHTTPError extends A2AClientError
Client exception indicating an HTTP transport error with a specific status code.

This exception is thrown when HTTP communication with an A2A agent fails, capturing both the HTTP status code and error message. It is used for non-2xx HTTP responses that don't contain valid A2A Protocol error responses.

Common HTTP status codes:

  • 4xx - Client errors (400 Bad Request, 401 Unauthorized, 404 Not Found, etc.)
  • 5xx - Server errors (500 Internal Server Error, 503 Service Unavailable, etc.)

This exception is set as the cause of A2AClientException so that callers can inspect the HTTP status code while remaining backward compatible:


  catch (A2AClientException e) {
     if (e.getCause() instanceof A2AClientHTTPError httpError) {
         int status = httpError.getCode();           // e.g. 401, 503
         String body = httpError.getResponseBody();  // raw response body, may be null
     }
 }
 }
See Also:
  • Constructor Details

    • A2AClientHTTPError

      @Deprecated(since="1.0.0.Beta1", forRemoval=true) public A2AClientHTTPError(int code, String message, Object data)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Use A2AClientHTTPError(int, String, String) instead to preserve the response body.
      Creates a new HTTP client error with the specified status code and message.
      Parameters:
      code - the HTTP status code
      message - the error message
      data - additional error data (may be the response body)
      Throws:
      IllegalArgumentException - if code or message is null
    • A2AClientHTTPError

      public A2AClientHTTPError(int code, String message, @Nullable String responseBody)
      Creates a new HTTP client error with the specified status code, message, and response body.
      Parameters:
      code - the HTTP status code (e.g. 401, 503)
      message - the error message
      responseBody - the raw HTTP response body, may be null
  • Method Details

    • getCode

      public int getCode()
      Gets the HTTP status code.
      Returns:
      the HTTP status code (e.g. 401, 404, 500, 503)
    • getMessage

      public String getMessage()
      Gets the error message.
      Overrides:
      getMessage in class Throwable
      Returns:
      the error message
    • getResponseBody

      public @Nullable String getResponseBody()
      Returns the raw HTTP response body, if available.
      Returns:
      the response body, or null if not available