Schooner.Error exception (schooner v1.2.0)

Copy Markdown View Source

Host-side exception raised when a Scheme raise / raise-continuable / error is not caught by any installed with-exception-handler or guard. The struct carries the original Scheme value verbatim in :value; for an error object the host can pattern-match {:error_obj, kind, message, irritants} directly, or use irritants/1 for the common case.

This is distinct from Schooner.Eval.Error and Schooner.Primitive.Error, which signal evaluator and primitive failures. Those reach the host directly without passing through the Scheme exception handlers. Values raised from Scheme or through Schooner.Host.raise_error/2 and Schooner.Host.raise_value/1 end up here when unhandled. Host code should use those helpers for errors scripts can catch; raising Schooner.Error directly bypasses Scheme handlers.

:location is the Schooner.Location of the call that raised the value. It is only filled in when the script runs with debug: true; see "Source locations" in Schooner. With debug: true, :scheme_backtrace lists the procedure calls that led to the raise, most recent first (see Schooner.Frame); otherwise it is nil.

Summary

Functions

Return the irritants of error's wrapped value when it is an error object; [] for any other raised value.

Types

t()

@type t() :: %Schooner.Error{
  __exception__: true,
  location: Schooner.Location.t() | nil,
  message: binary() | nil,
  scheme_backtrace: [Schooner.Frame.t()] | nil,
  value: Schooner.Value.t()
}

Functions

irritants(error)

@spec irritants(t()) :: [Schooner.Value.t()]

Return the irritants of error's wrapped value when it is an error object; [] for any other raised value.