JSONRPC2. Spec. Error
(jsonrpc2_spec v0.2.0)
Copy Markdown
Struct which represents JSONRPC error.
Summary
Functions
Create error struct with predefined errors.
Create error struct.
Create error struct with custom errors.
Types
@type code() :: integer()
@type message() :: String.t()
@type t() :: %JSONRPC2.Spec.Error{ error: error(), id: JSONRPC2.Spec.id(), jsonrpc: String.t() }
Functions
@spec new(JSONRPC2.Spec.id(), atom()) :: t()
Create error struct with predefined errors.
Example:
iex> Error.new("123", :invalid_request)
%Error{id: "123", error: %{code: -32600, message: "Invalid request"}, jsonrpc: "2.0"}
@spec new(JSONRPC2.Spec.id(), raw_code(), message() | data()) :: t()
Create error struct.
Example:
iex> Error.new("123", :invalid_params, %{"x" => ["is not a integer"]})
%Error{id: "123", error: %{code: -32602, message: "Invalid params", data: %{"x" => ["is not a integer"]}}, jsonrpc: "2.0"}
iex> Error.new("123", 500, "Some valuable error")
%Error{id: "123", error: %{code: 500, message: "Some valuable error"}, jsonrpc: "2.0"}
@spec new(JSONRPC2.Spec.id(), raw_code(), message(), data()) :: t()
Create error struct with custom errors.
Example:
iex> Error.new("123", 500, "Some valuable error", "details")
%Error{id: "123", error: %{code: 500, message: "Some valuable error", data: "details"}, jsonrpc: "2.0"}