Repository navigation
Expand file tree
/
Copy pathA2AClientHTTPError.java
More file actions
61 lines (56 loc) · 1.65 KB
/
Copy pathA2AClientHTTPError.java
File metadata and controls
61 lines (56 loc) · 1.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package io.a2a.spec;
import io.a2a.util.Assert;
/**
* Client exception indicating an HTTP transport error with a specific status code.
* <p>
* 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.
* <p>
* Common HTTP status codes:
* <ul>
* <li>4xx - Client errors (400 Bad Request, 401 Unauthorized, 404 Not Found, etc.)</li>
* <li>5xx - Server errors (500 Internal Server Error, 503 Service Unavailable, etc.)</li>
* </ul>
* <p>
* Usage example:
* <pre>{@code
* if (response.statusCode() >= 400) {
* throw new A2AClientHTTPError(
* response.statusCode(),
* "HTTP error: " + response.statusMessage(),
* response.body()
* );
* }
* }</pre>
*
* @see A2AClientError for the base client error class
* @see <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Status">HTTP Status Codes</a>
*/
public class A2AClientHTTPError extends A2AClientError {
private final int code;
private final String message;
public A2AClientHTTPError(int code, String message, Object data) {
Assert.checkNotNullParam("code", code);
Assert.checkNotNullParam("message", message);
this.code = code;
this.message = message;
}
/**
* Gets the error code
*
* @return the error code
*/
public int getCode() {
return code;
}
/**
* Gets the error message
*
* @return the error message
*/
@Override
public String getMessage() {
return message;
}
}