JSONRPCResponse
Represents a JSON-RPC 2.0 response.
Per the specification, a response contains either a result on success or an error on failure — never both and never neither. This sealed hierarchy makes that invariant unrepresentable at compile time.
Type Parameters
T
The type of the successful result value.
E
The type of the error's optional data field.
Example:
val success: JSONRPCResponse<Int, Nothing> = JSONRPCResponse.Success(
id = RequestId(1),
result = 42,
)
val failure: JSONRPCResponse<Nothing, Nothing> = JSONRPCResponse.Error(
id = RequestId(1),
error = JSONRPCError.methodNotFound("tools/call"),
)Content copied to clipboard
See also
Inheritors
Types
Link copied to clipboard
data class Error<out E>(val id: RequestId?, val error: JSONRPCError<E>) : JSONRPCResponse<Nothing, E>
A failed JSON-RPC 2.0 response carrying an error object.