Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: