Exth.Rpc.Response (Exth v0.2.1)
View SourceRepresents JSON-RPC 2.0 response structures.
A response can be either a Success
or an Error
:
Success
- Contains the result of a successful RPC callid
- Request identifier (matches the request)result
- The actual response datajsonrpc
- JSON-RPC version (defaults to "2.0")
Error
- Contains error information when the RPC call failsid
- Request identifier (matches the request)error.code
- Integer error codeerror.message
- Error descriptionerror.data
- Optional additional error detailsjsonrpc
- 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
@type t() :: Exth.Rpc.Response.Success.t() | Exth.Rpc.Response.Error.t()
Functions
@spec error(Exth.Rpc.id(), integer(), String.t(), any() | nil) :: Exth.Rpc.Response.Error.t()
@spec success(Exth.Rpc.id(), String.t()) :: Exth.Rpc.Response.Success.t()