ex_messagebird v0.1.0 ExMessagebird.Error

Link to this section Summary

Functions

Converts an error code to an atom

Creates an Error struct from the JSON error object returned by the messagebird API.

Returns a list of Error structs from a Messagebird API error response.

Link to this section Types

Link to this type

code()

code() ::
  :request_not_allowed
  | :missing_params
  | :invalid_params
  | :not_found
  | :bad_request
  | :not_enough_balance
  | :api_not_found
  | :internal_error
  | :unknown
Link to this type

t()

t() :: %ExMessagebird.Error{
  code: ExMessagebird.Error.code(),
  description: String.t(),
  parameter: String.t()
}

Link to this section Functions

Link to this function

code_to_atom(integer)

Converts an error code to an atom

Exanples

iex> ExMessagebird.Error.code_to_atom(2) :request_not_allowed

iex> ExMessagebird.Error.code_to_atom(9) :missing_params

iex> ExMessagebird.Error.code_to_atom(10) :invalid_params

iex> ExMessagebird.Error.code_to_atom(20) :not_found

iex> ExMessagebird.Error.code_to_atom(21) :bad_request

iex> ExMessagebird.Error.code_to_atom(25) :not_enough_balance

iex> ExMessagebird.Error.code_to_atom(98) :api_not_found

iex> ExMessagebird.Error.code_to_atom(99) :internal_error

iex> ExMessagebird.Error.code_to_atom(101) :unknown

Link to this function

from_json(arg1)

Creates an Error struct from the JSON error object returned by the messagebird API.

Example JSON:

{
  "code": 2,
  "description": "Request not allowed (incorrect access_key)",
  "parameter": "access_key"
}
Link to this function

from_response(arg1)

Returns a list of Error structs from a Messagebird API error response.

Example: https://developers.messagebird.com/api#api-errors