Exceptional v1.0.7 Exceptional.Control
Exception control flow
Summary
Macros
Branch on if the value is an Exception
, applying the associated function for
that case. Does not catch thrown exceptions
Macros
Branch on if the value is an Exception
, applying the associated function for
that case. Does not catch thrown exceptions.
Examples
iex> use Exceptional.Control
...> branch 1,
...> value_do: fn v -> v + 1 end.(),
...> exception_do: fn ex -> ex end.()
2
iex> use Exceptional.Control
...> branch ArgumentError.exception("error message"),
...> value_do: fn v -> v end.(),
...> exception_do: fn %{message: msg} -> msg end.()
"error message"
iex> use Exceptional.Control
...> branch Enum.fetch!([], 99),
...> value_do: fn v -> v + 1 end.(),
...> exception_do: fn ex -> ex end.()
** (Enum.OutOfBoundsError) out of bounds error