Rover.Error exception (Rover v0.1.0)

Copy Markdown View Source

Structured error returned by Rover functions.

Rover.fetch/2 and browser commands return {:error, %Rover.Error{}} on failure — never raise. Pattern match on :reason to dispatch recovery:

case Rover.fetch(url) do
  {:ok, result} ->
    handle(result)

  {:error, %Rover.Error{reason: :timeout}} ->
    Logger.warning("slow page: #{url}")
    :skip

  {:error, %Rover.Error{reason: :proxy}} ->
    retry_direct(url)
end

Reason atoms

  • :timeout — page load exceeded the configured timeout.
  • :navigation — URL could not be reached (DNS, TLS, connection reset).
  • :selector_not_found — a selector expected by the operation did not match.
  • :selector_timeoutwait_for selector did not appear in time.
  • :evaluation — JavaScript evaluation threw.
  • :proxy — proxy connection failed.
  • :invalid_argument — malformed argument (bad URL, unknown option, etc.).
  • :runtime — internal runtime error (NIF / subprocess / wire protocol).
  • :shutdown — runtime is shutting down and refused the request.
  • :port_died — the runtime subprocess exited unexpectedly.

Summary

Functions

Build an error from the runtime's wire representation.

Types

reason()

@type reason() ::
  :timeout
  | :navigation
  | :selector_not_found
  | :selector_timeout
  | :evaluation
  | :proxy
  | :invalid_argument
  | :runtime
  | :shutdown
  | :port_died

t()

@type t() :: %Rover.Error{__exception__: true, message: String.t(), reason: reason()}

Functions

from_wire(map)

@spec from_wire(map()) :: t()

Build an error from the runtime's wire representation.