Lua.VM.ArgumentError exception (Lua v1.0.0-rc.0)
View SourceRaised when a function is called with invalid arguments.
This exception provides standardized error messages for bad arguments across all Lua standard library functions.
Fields
:function_name- The fully qualified function name (e.g., "string.rep"):arg_num- The argument number (1-based):expected- What type or value was expected (e.g., "number", "string"):got- What was actually received (optional, e.g., "nil", "boolean"):details- Additional details about the error (optional):line- Source line where the call originated (auto-populated fromLua.VM.Executor.current_position/0when not given explicitly):source- Source name where the call originated (auto-populated):call_stack- Call stack frames at the raise site (default[])
Examples
# Basic type error — line/source filled in automatically when raised
# from inside a Lua execution.
raise ArgumentError,
function_name: "string.rep",
arg_num: 2,
expected: "number"
# With actual type received
raise ArgumentError,
function_name: "string.sub",
arg_num: 2,
expected: "number",
got: "string"
# With additional details
raise ArgumentError,
function_name: "string.char",
arg_num: 1,
expected: "number",
details: "value out of range"
Summary
Functions
Creates an ArgumentError for type mismatches.
Creates an ArgumentError when no value is provided for a required argument.