Exceptional v2.1.3 Exceptional.TaggedStatus View Source

Convert back to conventional Erlang/Elixir {:ok, _} tuples

Convenience uses

Everything:

use Exceptional.TaggedStatus

Only named functions (to_tagged_status, ok):

use Exceptional.TaggedStatus, only: :named_functions

Only operators (~~~):

use Exceptional.TaggedStatus, only: :operators

Link to this section Summary

Functions

Alias for to_tagged_status

Convert unraised exceptions to {:error, message}, and other values to {:ok, value}

Operator alias for to_tagged_status

Link to this section Functions

Alias for to_tagged_status

Examples

iex> [1,2,3] |> ok()
{:ok, [1,2,3]}

iex> Enum.OutOfBoundsError.exception("error message") |> ok
{:error, "error message"}
Link to this function

to_tagged_status(maybe_exception) View Source

Convert unraised exceptions to {:error, message}, and other values to {:ok, value}.

Examples

iex> to_tagged_status([1,2,3])
{:ok, [1,2,3]}

iex> Enum.OutOfBoundsError.exception("error message") |> to_tagged_status()
{:error, "error message"}

Operator alias for to_tagged_status

Examples

iex> ~~~[1,2,3]
{:ok, [1,2,3]}

iex> ~~~Enum.OutOfBoundsError.exception("error message")
{:error, "error message"}

iex> exc = Enum.OutOfBoundsError.exception("error message")
...> ~~~exc
{:error, "error message"}