Tyrex.Error exception (Tyrex v0.4.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, was killed, or was stopped while a call was in flight)
    • :timeout — An eval exceeded its :timeout deadline. The V8 isolate was terminated, so the runtime is dead and must be replaced
    • :heap_limit_error — The guest exceeded the runtime's :max_heap_mb cap. The isolate was terminated, so the runtime is dead
    • :unsupported_option — The requested combination of options cannot be served. Two producers: blocking: true on a runtime with the :apply bridge enabled, which would deadlock, and timeout: :infinity on either eval path, which would arm no deadline at all
  • :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.