Hacker News new | ask | show | jobs
by arthurbrown 2526 days ago
What happens with this code when err isn't recoverable?

you can manage it a few ways in Elixir, struct matching is one:

  def perform(param) do
    res =
      case get_resource(param) do
        {:ok, val} -> val
        {:error, %RecoverableError{alternative_value: val}} -> val
      end

    do_more_things(res)
  end