Packages

Playwright is an Elixir library to automate Chromium, Firefox and WebKit browsers with a single API. Playwright delivers automation that is ever-green, capable, reliable and fast.

Current section

Files

Jump to
playwrightais lib playwright helpers error_handling.ex
Raw

lib/playwright/helpers/error_handling.ex

defmodule Playwright.Helpers.ErrorHandling do
@moduledoc false
alias Playwright.Channel.Error
def with_timeout(options, action) when is_map(options) and is_function(action) do
timeout = options |> Map.get(:timeout, 30_000)
try do
action.(timeout)
catch
:exit, {:timeout, _} = _reason ->
{:error, Error.new(%{error: %{message: "Timeout #{inspect(timeout)}ms exceeded."}}, nil)}
end
end
end