Obscurax.Error exception (obscurax v0.1.0)

Copy Markdown View Source

Structured error for all Obscurax operations.

All NIF operations return {:ok, result} or {:error, %Obscurax.Error{}}. Bang variants (goto!/2, etc.) raise this as an exception.

The context map carries operation-specific details that vary by kind:

kindcontext fields
:navigationurl
:timeouturl or selector + timeout_ms
:element_not_foundselector and/or node_id
:js_evalexpression
:no_page(empty)
:page_closed(empty)
:internal(empty)

All context keys are atoms. Fields not relevant to a given kind are nil.

Summary

Types

context()

@type context() :: %{
  optional(:url) => String.t(),
  optional(:selector) => String.t(),
  optional(:timeout_ms) => non_neg_integer(),
  optional(:node_id) => non_neg_integer(),
  optional(:expression) => String.t(),
  optional(atom()) => term()
}

kind()

@type kind() ::
  :navigation
  | :js_eval
  | :timeout
  | :element_not_found
  | :no_page
  | :page_closed
  | :internal

t()

@type t() :: %Obscurax.Error{
  __exception__: term(),
  context: context(),
  kind: kind(),
  message: String.t()
}