Package io.a2a.spec
Class A2AClientHTTPError
java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
io.a2a.spec.A2AClientError
io.a2a.spec.A2AClientHTTPError
- All Implemented Interfaces:
Serializable
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.)
Usage example:
if (response.statusCode() >= 400) {
throw new A2AClientHTTPError(
response.statusCode(),
"HTTP error: " + response.statusMessage(),
response.body()
);
}
-
Constructor Summary
ConstructorsConstructorDescriptionA2AClientHTTPError(int code, String message, Object data) Creates a new HTTP client error with the specified status code and message. -
Method Summary
Methods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
-
Constructor Details
-
A2AClientHTTPError
Creates a new HTTP client error with the specified status code and message.- Parameters:
code- the HTTP status codemessage- the error messagedata- additional error data (may be the response body)- Throws:
IllegalArgumentException- if code or message is null
-
-
Method Details
-
getCode
public int getCode()Gets the error code- Returns:
- the error code
-
getMessage
Gets the error message- Overrides:
getMessagein classThrowable- Returns:
- the error message
-