OkThen.Result.error_retag
You're seeing just the function
error_retag
, go back to OkThen.Result module for more information.
Link to this function
error_retag(result, new_tag)
Specs
error_retag(result_input(), new_tag) :: new_tag | {new_tag, any()} when new_tag: atom()
If result
is tagged :error
, replaces the tag with new_tag
, returning a new tagged tuple.
Equivalent to tagged_retag(result, :error, new_tag)
. See tagged_retag/3
.
Examples
iex> :error |> Result.error_retag(:none)
:none
iex> {:error, "hello"} |> Result.error_retag(:ok)
{:ok, "hello"}
iex> {:error, 1, 2} |> Result.error_retag(:ok)
{:ok, {1, 2}}
iex> {:ok, 1, 2} |> Result.error_retag(:error)
{:ok, 1, 2}
iex> :error |> Result.error_retag("string")
** (ArgumentError) Expected atom as new tag, got: "string".
iex> "bare value" |> Result.error_retag(:ok)
"bare value"