# opts = %{skip: ["regex expression"]}
def start_link(opts) do
Map.get(opts, :skip, %{})
|> Enum.map(&compile_regex/1)
GenServer.start_link(__MODULE__, 0)
end
defp compile_regex(entry) do
case Regex.compile(entry) do
{:ok, expr} -> expr
{:error, reason} -> {:error, reason}
end
end
The problem with this approach is that I’ll be parsing new entries even if there is already a failure. How can I stop on the first failure?