Phoenix API Toolkit v0.4.0 PhoenixApiToolkit.Utils View Source
Generic utility functions.
Link to this section Summary
Functions
Get a mandatory value from a keyword list.
Raises an ArgumentError if the key is missing from the list
(or its value is nil
).
Link to this section Functions
Get a mandatory value from a keyword list.
Raises an ArgumentError if the key is missing from the list
(or its value is nil
).
Examples
# if the key-value pair is present, its value is returned
iex> [secret: "supersecret"] |> get_keyword!(:secret)
"supersecret"
# if the key-value pair is not present, an error is raised
iex> [] |> get_keyword!(:secret)
** (ArgumentError) key "secret" not found
# if the value is nil, an error is raised
iex> [secret: nil] |> get_keyword!(:secret)
** (ArgumentError) key "secret" not found