OkThen.Result.from_error
You're seeing just the function
from_error
, go back to OkThen.Result module for more information.
Link to this function
from_error(value)
Specs
from_error(e) :: maybe_error(e) when e: any()
Converts value
into a maybe_error(e)
result: {:error, value} | :none
If value
is nil
, then the result will be :none
. See also from_error!/1
.
Otherwise, the result will be a two-element tuple, where the first element is :error
, and the
second element is value
.
Examples
iex> Result.from_error("hello")
{:error, "hello"}
iex> Result.from_error({1, 2})
{:error, {1, 2}}
iex> Result.from_error({})
:error
iex> Result.from_error(nil)
:none