WaEmbedder.ImportError exception (WaEmbedderEx v0.1.0)

Copy Markdown View Source

Raised when a module's WASM import section cannot be satisfied at compile time.

Three independent failure modes are reported, and a given raise populates exactly one of them (the others stay []):

  • unresolved — function imports the module declares that have no matching entry in the imports map passed to WaEmbedder.compile/3. A list of {module_name, func_name} string pairs.

  • unsupported — non-function imports (memory, table, global, tag), which this embedder does not support. A list of {module_name, name, kind} tuples where kind is :memory, :table, :global, or :tag.

  • invalid — function imports whose bound target is unusable. A list of {module_name, func_name, reason} tuples where reason is:

    • :closure_unsupported — the target is a closure capturing environment (bind it to an MFA or &Mod.fun/arity capture, or use the closure-import mechanism);
    • :unrecognized_target — the target is neither an {Module, :function} tuple nor a function reference;
    • {:arity_mismatch, expected, got} — the target's arity does not match the parameter count of the WASM function type it is bound to.

Summary

Types

invalid_reason()

@type invalid_reason() ::
  :closure_unsupported
  | :unrecognized_target
  | {:arity_mismatch, non_neg_integer(), term()}

t()

@type t() :: %WaEmbedder.ImportError{
  __exception__: true,
  invalid: [{String.t(), String.t(), invalid_reason()}],
  message: String.t() | nil,
  unresolved: [{String.t(), String.t()}],
  unsupported: [{String.t(), String.t(), atom()}]
}