Schooner.Host.TypeError exception (schooner v1.2.0)

Copy Markdown View Source

Raised by Schooner.Host asserting accessors (to_*!/2) when a Scheme value does not match the shape the host expected.

The exception carries :op (a host-supplied label naming the call site, e.g. "my-lib/info"), :expected (a short description of the shape that was demanded, e.g. "string", "proper list"), and :got (the actual value, rendered with inspect/1 in the message). Callers can match on :op and :expected without depending on the message wording.

:location is the Schooner.Location of the script call that reached the host function. 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 error, most recent first (see Schooner.Frame); otherwise it is nil.

Summary

Types

t()

@type t() :: %Schooner.Host.TypeError{
  __exception__: true,
  expected: binary(),
  got: term(),
  location: Schooner.Location.t() | nil,
  message: binary(),
  op: binary(),
  scheme_backtrace: [Schooner.Frame.t()] | nil
}