Errors
List of errors
Attempt to call a nil value
Description: calling a function that doesn't exist
Example:
Unexpected symbol near 'something'
Description: an invalid character is placed next to a value/keyword/variable/function call
Attempt to index global 'variable' (a nil value)
Description: indexing via [key]
or .key
for a variable that doesn't exist
Example:
Attempt to perform arithmetic on a nil value
Description: performing arithmetic (*, /, -, +, %, ^) on a nil value
Example:
Attempt to perform arithmetic on field '?' (a nil value)
Description: performing arithmetic (*, /, -, +, %, ^) on a nil value
Example:
Attempt to compare nil with <TYPE>
Description: using a comparison operator (<, >, ~=, ==, >=, <=) in which one side is a nil value
Example:
Malformed number near <NUMBER>
Description: the number has an invalid character next to it
Example:
Unfinished capture | Malformed pattern
Description: the pattern is missing a closing )
, or a closing ]
Example:
Interpreting errors
When you get an error, Lua provides a stack trace showing you where it originates from, where the error occurs, the function calls that led to the error, and the line number of where it occurred.
A general error will look like this:
Here's an example:
The code that resulted in this error is:
Here you can see the line number 5
after the file location, which tells us where the exact line with the code that resulted in the error. The stack traceback shows the functions that were called that led up to that.
First, function a
is called at line 12, then function b
is called at line 9 inside of a
, then c
is called at line 7 inside of function b
, and finally at line 5, the error occurs inside of function c
.
A note to add is that comments can offset the line number and make it appear as the error is in a line that doesn't exist or doesn't look like an error,
Last updated