Lua.VM.TypeError exception (Lua v1.0.0-rc.2)

View Source

Raised when a Lua operation is applied to a value of the wrong type.

Examples: calling a nil value, calling a number, indexing a boolean.

When raised without explicit :line / :source opts (e.g. from a stdlib type check), exception/1 populates them from the calling Lua source position via Lua.VM.Executor.current_position/0. That position is stashed in the process dictionary at every native-call boundary, so any raise site reachable from a Lua execution inherits the correct attribution automatically.

Summary

Functions

Returns a wire-safe structured map for this error. See Lua.VM.ErrorFormatter.to_map/3 for the shape.

Types

t()

@type t() :: %Lua.VM.TypeError{
  __exception__: true,
  call_stack: term(),
  error_kind: term(),
  line: term(),
  message: term(),
  source: term(),
  state: term(),
  value: term(),
  value_type: term()
}

Functions

to_map(error, opts \\ [])

@spec to_map(
  t(),
  keyword()
) :: map()

Returns a wire-safe structured map for this error. See Lua.VM.ErrorFormatter.to_map/3 for the shape.

Pass :source_code to populate source_context.