Tyrex.Error exception (Tyrex v0.3.0)

Copy Markdown View Source

Exception struct for Tyrex runtime errors.

Fields:

  • :name - Error type atom. One of:
    • :execution_error — JS/TS code raised or failed to compile
    • :promise_rejection — Returned promise rejected; :value holds the decoded rejection value
    • :conversion_error — A value could not be converted between Elixir and JavaScript representations
    • :dead_runtime_error — The underlying runtime is no longer alive (e.g. crashed or was stopped while a call was in flight)
  • :message - Human-readable error message (optional)
  • :value - Additional error value, such as the rejected promise value (optional)

Summary

Types

t()

A Tyrex.Error exception with a tagged :name, optional human-readable :message, and an optional :value payload (used for promise rejections).

Functions

Build a Tyrex.Error exception from a keyword list.

Format a Tyrex.Error as a human-readable string. Used by Elixir when the exception is raised or inspected via Exception.message/1.

Types

t()

@type t() :: %Tyrex.Error{
  __exception__: term(),
  message: String.t() | nil,
  name: atom(),
  value: term() | nil
}

A Tyrex.Error exception with a tagged :name, optional human-readable :message, and an optional :value payload (used for promise rejections).

Functions

exception(msg)

@spec exception(Keyword.t()) :: t()

Build a Tyrex.Error exception from a keyword list.

Required: :name. Optional: :message, :value. This is the callback used by raise Tyrex.Error, name: :dead_runtime_error and similar.

message(exception)

@spec message(t()) :: String.t()

Format a Tyrex.Error as a human-readable string. Used by Elixir when the exception is raised or inspected via Exception.message/1.