Exth.Rpc.Response (Exth v0.2.1)

View Source

Represents JSON-RPC 2.0 response structures.

A response can be either a Success or an Error:

  • Success - Contains the result of a successful RPC call

    • id - Request identifier (matches the request)
    • result - The actual response data
    • jsonrpc - JSON-RPC version (defaults to "2.0")
  • Error - Contains error information when the RPC call fails

    • id - Request identifier (matches the request)
    • error.code - Integer error code
    • error.message - Error description
    • error.data - Optional additional error details
    • jsonrpc - JSON-RPC version (defaults to "2.0")

Examples

# Creating a success response
Response.success(1, "0x1234")
#=> %Response.Success{id: 1, result: "0x1234", jsonrpc: "2.0"}

# Creating an error response
Response.error(1, -32600, "Invalid Request")
#=> %Response.Error{
  id: 1,
  error: %{code: -32600, message: "Invalid Request", data: nil},
  jsonrpc: "2.0"
}

Summary

Types

Functions

error(id, code, message, data \\ nil)

@spec error(Exth.Rpc.id(), integer(), String.t(), any() | nil) ::
  Exth.Rpc.Response.Error.t()

success(id, result)