public class AcpProtocolException extends AcpException
This exception is thrown when the peer returns a JSON-RPC error response. It wraps the error code, message, and optional data from the protocol response.
Common error codes are defined in AcpErrorCodes:
AcpErrorCodes.METHOD_NOT_FOUND (-32601): Method not availableAcpErrorCodes.INVALID_PARAMS (-32602): Invalid parametersAcpErrorCodes.INTERNAL_ERROR (-32603): Internal errorAcpErrorCodes.CONCURRENT_PROMPT (-32000): Already processing a promptExample usage:
try {
client.prompt(request).block();
} catch (AcpProtocolException e) {
if (e.getCode() == AcpErrorCodes.CONCURRENT_PROMPT) {
// Handle concurrent prompt error
}
}
AcpErrorCodes,
序列化表格| 构造器和说明 |
|---|
AcpProtocolException(AcpSchema.JSONRPCError error)
Constructs a new protocol exception from a JSON-RPC error.
|
AcpProtocolException(int code,
java.lang.String message)
Constructs a new protocol exception with the specified code and message.
|
AcpProtocolException(int code,
java.lang.String message,
java.lang.Object data)
Constructs a new protocol exception with the specified code, message, and data.
|
| 限定符和类型 | 方法和说明 |
|---|---|
int |
getCode()
Returns the JSON-RPC error code.
|
java.lang.Object |
getData()
Returns the optional additional error data.
|
boolean |
isConcurrentPrompt()
Returns true if this error indicates a concurrent prompt violation.
|
boolean |
isInternalError()
Returns true if this error indicates an internal error.
|
boolean |
isInvalidParams()
Returns true if this error indicates invalid parameters.
|
boolean |
isMethodNotFound()
Returns true if this error indicates the method was not found.
|
AcpSchema.JSONRPCError |
toJsonRpcError()
Converts this exception to a JSON-RPC error object for sending over the wire.
|
public AcpProtocolException(AcpSchema.JSONRPCError error)
error - the JSON-RPC error from the protocol responsepublic AcpProtocolException(int code,
java.lang.String message)
code - the JSON-RPC error codemessage - the error messagepublic AcpProtocolException(int code,
java.lang.String message,
java.lang.Object data)
code - the JSON-RPC error codemessage - the error messagedata - optional additional error datapublic int getCode()
AcpErrorCodespublic java.lang.Object getData()
public AcpSchema.JSONRPCError toJsonRpcError()
public boolean isMethodNotFound()
public boolean isConcurrentPrompt()
public boolean isInvalidParams()
public boolean isInternalError()