Lua.CompilerException exception (Lua v1.0.1)

View Source

Raised when Lua source cannot be lexed, parsed, or compiled.

Exception.message/1 returns a plain, ANSI-free string — the bare per-error messages under a Failed to compile Lua! header — safe to log. For the full, human-readable report (location, source context, pointer, suggestions, and ANSI color on a TTY) use Lua.format_exception/1, which is what mix lua.eval prints. For structured data use to_map/1.

The :errors field carries the bare, ANSI-free error messages (no location header or source context) for programmatic inspection and clean logging.

Summary

Functions

Renders the rich, human-readable report — location, source context, a pointer to the offending token, and suggestions — with ANSI color when IO.ANSI.enabled?/0 is true. Used by Lua.format_exception/1.

Returns a wire-safe structured representation — a list of per-error maps in the Lua.Parser.Error shape (type, message, line, source_context, suggestion, …), with no ANSI escapes. Returns [] for non-parser inputs (lexer/compiler errors) that carry no structured diagnostics; read :errors for those.

Types

t()

@type t() :: %Lua.CompilerException{
  __exception__: true,
  diagnostics: term(),
  errors: term(),
  source: term()
}

Functions

format(e)

@spec format(t()) :: String.t()

Renders the rich, human-readable report — location, source context, a pointer to the offending token, and suggestions — with ANSI color when IO.ANSI.enabled?/0 is true. Used by Lua.format_exception/1.

Compile-time errors have no runtime stack trace; the context is rendered from the structured :diagnostics. Falls back to the plain message/1 when no structured diagnostics are present (lexer/compiler errors).

to_map(compiler_exception)

@spec to_map(t()) :: [map()]

Returns a wire-safe structured representation — a list of per-error maps in the Lua.Parser.Error shape (type, message, line, source_context, suggestion, …), with no ANSI escapes. Returns [] for non-parser inputs (lexer/compiler errors) that carry no structured diagnostics; read :errors for those.