Class JsonRpcException
java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
com.github.copilot.JsonRpcException
- All Implemented Interfaces:
Serializable
Exception thrown when a JSON-RPC error occurs during communication with the
Copilot CLI server.
This exception wraps error responses from the JSON-RPC protocol, including
the error code, message, and optional raw JSON data returned by the server.
Calls to CompletableFuture.get() wrap this
exception in an ExecutionException; calls to
CompletableFuture.join() wrap it in a
CompletionException.
- Since:
- 1.0.15-preview.1
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionJsonRpcException(int code, String message) Creates a new JSON-RPC exception.JsonRpcException(int code, String message, com.fasterxml.jackson.databind.JsonNode data) Creates a new JSON-RPC exception with optional raw JSON error data. -
Method Summary
Methods inherited from class Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
-
Constructor Details
-
JsonRpcException
Creates a new JSON-RPC exception.- Parameters:
code- the JSON-RPC error codemessage- the error message from the server
-
JsonRpcException
Creates a new JSON-RPC exception with optional raw JSON error data.- Parameters:
code- the JSON-RPC error codemessage- the error message from the serverdata- the error data, ornullif omitted; a JSON null is represented by aNullNode- Since:
- 1.0.15-preview.1
-
-
Method Details
-
getCode
public int getCode()Returns the JSON-RPC error code.Standard JSON-RPC error codes include:
- -32700: Parse error
- -32600: Invalid request
- -32601: Method not found
- -32602: Invalid params
- -32603: Internal error
- Returns:
- the error code
-
getData
public com.fasterxml.jackson.databind.JsonNode getData()Returns the raw JSON error data without converting its value or shape.An omitted data member is represented by Java
null. An explicit JSON null is represented by aNullNode. This value is not included in the exception's message or string representation. The node is shared, not defensively copied; callers that modify container nodes should first useJsonNode.deepCopy().- Returns:
- the error data, or
nullif the server omitted it - Since:
- 1.0.15-preview.1
-