defmodule Foo do
def execute(table_name) do
case output = :ets.tab2list(table_name) do
ArgumentError -> execute(table_name)
_ -> output
end
end
end
iex(2)> Foo.execute(:bish)
** (ArgumentError) argument error
(stdlib 3.14) :ets.match_object(:bish, :_)
(stdlib 3.14) ets.erl:765: :ets.tab2list/1
The goal of the code above is to address a race condition that occurs when a function attempts to read an ETS table that is in the midst of being written to.
How does one pattern match against such an ArgumentError
?