JSONRPC2Plug.Error (jsonrpc2_plug v0.1.0)
Link to this section Summary
Functions
Create error struct with predefined errors.
Create error struct.
Create error struct with custom errors.
Link to this section Types
Link to this type
code()
Specs
code() :: integer()
Link to this type
data()
Specs
Link to this type
error()
Specs
Link to this type
id()
Specs
Link to this type
message()
Specs
message() :: String.t()
Link to this type
raw_code()
Specs
Specs
Link to this section Functions
Link to this function
code2error(code)
Specs
Link to this function
new(id, code)
Specs
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"}
Link to this function
new(id, code, message_or_data)
Specs
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"}
Link to this function
new(id, code, message, data)
Specs
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"}